diff options
| author | 2017-01-24 08:32:59 +0000 | |
|---|---|---|
| committer | 2017-01-24 08:32:59 +0000 | |
| commit | 53d771aafdbe5b919f264f53cba3788e2c4cffd2 (patch) | |
| tree | 7eca39498be0ff1e3a6daf583cd9ca5886bb2636 /gnu/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp | |
| parent | In preparation of compiling our kernels with -ffreestanding, explicitly map (diff) | |
| download | wireguard-openbsd-53d771aafdbe5b919f264f53cba3788e2c4cffd2.tar.xz wireguard-openbsd-53d771aafdbe5b919f264f53cba3788e2c4cffd2.zip | |
Import LLVM 4.0.0 rc1 including clang and lld to help the current
development effort on OpenBSD/arm64.
Diffstat (limited to 'gnu/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp')
| -rw-r--r-- | gnu/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/gnu/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp b/gnu/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp new file mode 100644 index 00000000000..afbbe004186 --- /dev/null +++ b/gnu/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp @@ -0,0 +1,58 @@ +//===-- RISCVTargetMachine.cpp - Define TargetMachine for RISCV -----------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Implements the info about RISCV target spec. +// +//===----------------------------------------------------------------------===// + +#include "RISCVTargetMachine.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" +#include "llvm/CodeGen/TargetPassConfig.h" +#include "llvm/IR/LegacyPassManager.h" +#include "llvm/CodeGen/Passes.h" +#include "llvm/Support/FormattedStream.h" +#include "llvm/Support/TargetRegistry.h" +#include "llvm/Target/TargetOptions.h" +using namespace llvm; + +extern "C" void LLVMInitializeRISCVTarget() { + RegisterTargetMachine<RISCVTargetMachine> X(getTheRISCV32Target()); + RegisterTargetMachine<RISCVTargetMachine> Y(getTheRISCV64Target()); +} + +static std::string computeDataLayout(const Triple &TT) { + if (TT.isArch64Bit()) { + return "e-m:e-i64:64-n32:64-S128"; + } else { + assert(TT.isArch32Bit() && "only RV32 and RV64 are currently supported"); + return "e-m:e-i64:64-n32-S128"; + } +} + +static Reloc::Model getEffectiveRelocModel(const Triple &TT, + Optional<Reloc::Model> RM) { + if (!RM.hasValue()) + return Reloc::Static; + return *RM; +} + +RISCVTargetMachine::RISCVTargetMachine(const Target &T, const Triple &TT, + StringRef CPU, StringRef FS, + const TargetOptions &Options, + Optional<Reloc::Model> RM, + CodeModel::Model CM, + CodeGenOpt::Level OL) + : LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options, + getEffectiveRelocModel(TT, RM), CM, OL), + TLOF(make_unique<TargetLoweringObjectFileELF>()) {} + +TargetPassConfig *RISCVTargetMachine::createPassConfig(PassManagerBase &PM) { + return new TargetPassConfig(this, PM); +} |
