LLVM  4.0.0
RISCVTargetMachine.cpp
Go to the documentation of this file.
1 //===-- RISCVTargetMachine.cpp - Define TargetMachine for RISCV -----------===//
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 // Implements the info about RISCV target spec.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "RISCVTargetMachine.h"
15 #include "llvm/ADT/STLExtras.h"
19 #include "llvm/CodeGen/Passes.h"
23 using namespace llvm;
24 
25 extern "C" void LLVMInitializeRISCVTarget() {
28 }
29 
30 static std::string computeDataLayout(const Triple &TT) {
31  if (TT.isArch64Bit()) {
32  return "e-m:e-i64:64-n32:64-S128";
33  } else {
34  assert(TT.isArch32Bit() && "only RV32 and RV64 are currently supported");
35  return "e-m:e-i64:64-n32-S128";
36  }
37 }
38 
41  if (!RM.hasValue())
42  return Reloc::Static;
43  return *RM;
44 }
45 
47  StringRef CPU, StringRef FS,
48  const TargetOptions &Options,
52  : LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options,
53  getEffectiveRelocModel(TT, RM), CM, OL),
55 
57  return new TargetPassConfig(this, PM);
58 }
bool hasValue() const
Definition: Optional.h:125
Target & getTheRISCV32Target()
Target-Independent Code Generator Pass Configuration Options.
bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition: Triple.cpp:1202
std::enable_if<!std::is_array< T >::value, std::unique_ptr< T > >::type make_unique(Args &&...args)
Constructs a new T() with the given args and returns a unique_ptr<T> which owns the object...
Definition: STLExtras.h:845
static Reloc::Model getEffectiveRelocModel(Optional< Reloc::Model > RM)
void LLVMInitializeRISCVTarget()
Target & getTheRISCV64Target()
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
This class describes a target machine that is implemented with the LLVM target-independent code gener...
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
Target - Wrapper for Target specific information.
static std::string computeDataLayout(const Triple &TT)
RISCVTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional< Reloc::Model > RM, CodeModel::Model CM, CodeGenOpt::Level OL)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
RegisterTargetMachine - Helper template for registering a target machine implementation, for use in the target machine initialization function.
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml","ocaml 3.10-compatible collector")
bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition: Triple.cpp:1206