diff options
| author | Nikolai Bozhenov <nikolai.bozhenov@intel.com> | 2017-09-19 11:54:29 +0000 |
|---|---|---|
| committer | Nikolai Bozhenov <nikolai.bozhenov@intel.com> | 2017-09-19 11:54:29 +0000 |
| commit | ebbde1409f1a4eb5ef0550d72fdd11848f4fbf69 (patch) | |
| tree | aa280cde4974f3719476382ee157752dce8b7008 /llvm/lib/Target/Nios2/Nios2Subtarget.cpp | |
| parent | ccfb8d4fe87bbd8b6946395e2495e14ae716ee3d (diff) | |
| download | bcm5719-llvm-ebbde1409f1a4eb5ef0550d72fdd11848f4fbf69.tar.gz bcm5719-llvm-ebbde1409f1a4eb5ef0550d72fdd11848f4fbf69.zip | |
[Nios2] Subtarget, basic infrastructure for frame, instructions and registers
This is the second minimal patch keeping Nios2 target buildable.
I'm adding subtarget here and other stuff for frame lowering, instruction,
register information methods. I do not add any test cases, as still there
are missing parts like DAG selector and assembly printing. I plan to include
them into the next patch.
Patch by Andrei Grischenko <andrei.l.grischenko@intel.com>
Differential Revision: https://reviews.llvm.org/D37256
llvm-svn: 313626
Diffstat (limited to 'llvm/lib/Target/Nios2/Nios2Subtarget.cpp')
| -rw-r--r-- | llvm/lib/Target/Nios2/Nios2Subtarget.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/llvm/lib/Target/Nios2/Nios2Subtarget.cpp b/llvm/lib/Target/Nios2/Nios2Subtarget.cpp new file mode 100644 index 00000000000..6176d37fea0 --- /dev/null +++ b/llvm/lib/Target/Nios2/Nios2Subtarget.cpp @@ -0,0 +1,61 @@ +//===-- Nios2Subtarget.cpp - Nios2 Subtarget Information ------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements the Nios2 specific subclass of TargetSubtargetInfo. +// +//===----------------------------------------------------------------------===// + +#include "Nios2Subtarget.h" + +#include "Nios2.h" +#include "Nios2RegisterInfo.h" +#include "Nios2TargetMachine.h" + +using namespace llvm; + +#define DEBUG_TYPE "nios2-subtarget" + +#define GET_SUBTARGETINFO_TARGET_DESC +#define GET_SUBTARGETINFO_CTOR +#include "Nios2GenSubtargetInfo.inc" + +void Nios2Subtarget::anchor() {} + +Nios2Subtarget::Nios2Subtarget(const Triple &TT, const std::string &CPU, + const std::string &FS, + const Nios2TargetMachine &_TM) + : + + // Nios2GenSubtargetInfo will display features by llc -march=nios2 + // -mcpu=help + Nios2GenSubtargetInfo(TT, CPU, FS), TM(_TM), TargetTriple(TT), + InstrInfo(Nios2InstrInfo::create( + initializeSubtargetDependencies(CPU, FS, TM))) {} + +Nios2Subtarget & +Nios2Subtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS, + const TargetMachine &TM) { + if (TargetTriple.getArch() == Triple::nios2) { + if (CPU != "nios2r2") { + CPU = "nios2r1"; + Nios2ArchVersion = Nios2r1; + } else { + Nios2ArchVersion = Nios2r2; + } + } else { + errs() << "!!!Error, TargetTriple.getArch() = " << TargetTriple.getArch() + << "CPU = " << CPU << "\n"; + exit(0); + } + + // Parse features string. + ParseSubtargetFeatures(CPU, FS); + + return *this; +} |

