1 //===-- Nios2Subtarget.cpp - Nios2 Subtarget Information ------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the Nios2 specific subclass of TargetSubtargetInfo.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "Nios2Subtarget.h"
15 #include "Nios2.h"
16
17 using namespace llvm;
18
19 #define DEBUG_TYPE "nios2-subtarget"
20
21 #define GET_SUBTARGETINFO_TARGET_DESC
22 #define GET_SUBTARGETINFO_CTOR
23 #include "Nios2GenSubtargetInfo.inc"
24
anchor()25 void Nios2Subtarget::anchor() {}
26
Nios2Subtarget(const Triple & TT,const std::string & CPU,const std::string & FS,const TargetMachine & TM)27 Nios2Subtarget::Nios2Subtarget(const Triple &TT, const std::string &CPU,
28 const std::string &FS, const TargetMachine &TM)
29 :
30
31 // Nios2GenSubtargetInfo will display features by llc -march=nios2
32 // -mcpu=help
33 Nios2GenSubtargetInfo(TT, CPU, FS), TargetTriple(TT),
34 InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
35 FrameLowering(*this) {}
36
initializeSubtargetDependencies(StringRef CPU,StringRef FS)37 Nios2Subtarget &Nios2Subtarget::initializeSubtargetDependencies(StringRef CPU,
38 StringRef FS) {
39 if (TargetTriple.getArch() == Triple::nios2) {
40 if (CPU != "nios2r2") {
41 CPU = "nios2r1";
42 Nios2ArchVersion = Nios2r1;
43 } else {
44 Nios2ArchVersion = Nios2r2;
45 }
46 } else {
47 errs() << "!!!Error, TargetTriple.getArch() = " << TargetTriple.getArch()
48 << "CPU = " << CPU << "\n";
49 exit(0);
50 }
51
52 // Parse features string.
53 ParseSubtargetFeatures(CPU, FS);
54
55 return *this;
56 }
57