LLVM  14.0.0git
CSKYTargetMachine.cpp
Go to the documentation of this file.
1 //===--- CSKYTargetMachine.cpp - Define TargetMachine for CSKY ------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Implements the info about CSKY target spec.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "CSKYTargetMachine.h"
18 
19 using namespace llvm;
20 
23 }
24 
25 static std::string computeDataLayout(const Triple &TT) {
26  std::string Ret;
27 
28  // Only support little endian for now.
29  // TODO: Add support for big endian.
30  Ret += "e";
31 
32  // CSKY is always 32-bit target with the CSKYv2 ABI as prefer now.
33  // It's a 4-byte aligned stack with ELF mangling only.
34  Ret += "-m:e-S32-p:32:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:32:32"
35  "-v128:32:32-a:0:32-Fi32-n32";
36 
37  return Ret;
38 }
39 
41  StringRef CPU, StringRef FS,
42  const TargetOptions &Options,
45  CodeGenOpt::Level OL, bool JIT)
47  RM.getValueOr(Reloc::Static),
48  getEffectiveCodeModel(CM, CodeModel::Small), OL),
49  TLOF(std::make_unique<TargetLoweringObjectFileELF>()) {
50  initAsmInfo();
51 }
52 
53 namespace {
54 class CSKYPassConfig : public TargetPassConfig {
55 public:
56  CSKYPassConfig(CSKYTargetMachine &TM, PassManagerBase &PM)
57  : TargetPassConfig(TM, PM) {}
58 
59  CSKYTargetMachine &getCSKYTargetMachine() const {
60  return getTM<CSKYTargetMachine>();
61  }
62 };
63 
64 } // namespace
65 
67  return new CSKYPassConfig(*this, PM);
68 }
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::TargetOptions
Definition: TargetOptions.h:124
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:137
CSKYTargetMachine.h
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
llvm::TargetLoweringObjectFileELF
Definition: TargetLoweringObjectFileImpl.h:33
LLVMInitializeCSKYTarget
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeCSKYTarget()
Definition: CSKYTargetMachine.cpp:21
llvm::Optional< Reloc::Model >
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:116
llvm::getTheCSKYTarget
Target & getTheCSKYTarget()
Definition: CSKYTargetInfo.cpp:13
computeDataLayout
static std::string computeDataLayout(const Triple &TT)
Definition: CSKYTargetMachine.cpp:25
llvm::CodeModel::Small
@ Small
Definition: CodeGen.h:28
llvm::RegisterTargetMachine
RegisterTargetMachine - Helper template for registering a target machine implementation,...
Definition: TargetRegistry.h:1275
Options
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
Definition: PassBuilderBindings.cpp:48
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
llvm::CSKYTargetMachine::createPassConfig
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
Definition: CSKYTargetMachine.cpp:66
llvm::TargetPassConfig
Target-Independent Code Generator Pass Configuration Options.
Definition: TargetPassConfig.h:84
llvm::EngineKind::JIT
@ JIT
Definition: ExecutionEngine.h:524
LLVM_EXTERNAL_VISIBILITY
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:132
TargetPassConfig.h
llvm::X86AS::FS
@ FS
Definition: X86.h:188
llvm::AArch64::RM
@ RM
Definition: AArch64ISelLowering.h:472
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::CSKYTargetMachine
Definition: CSKYTargetMachine.h:21
llvm::CodeGenOpt::Level
Level
Definition: CodeGen.h:52
llvm::getEffectiveCodeModel
CodeModel::Model getEffectiveCodeModel(Optional< CodeModel::Model > CM, CodeModel::Model Default)
Helper method for getting the code model, returning Default if CM does not have a value.
Definition: TargetMachine.h:481
llvm::LLVMTargetMachine::initAsmInfo
void initAsmInfo()
Definition: LLVMTargetMachine.cpp:41
std
Definition: BitVector.h:838
llvm::LLVMTargetMachine
This class describes a target machine that is implemented with the LLVM target-independent code gener...
Definition: TargetMachine.h:393
llvm::CSKYTargetMachine::CSKYTargetMachine
CSKYTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional< Reloc::Model > RM, Optional< CodeModel::Model > CM, CodeGenOpt::Level OL, bool JIT)
Definition: CSKYTargetMachine.cpp:40
CSKYTargetInfo.h
llvm::legacy::PassManagerBase
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
Definition: LegacyPassManager.h:39
TM
const char LLVMTargetMachineRef TM
Definition: PassBuilderBindings.cpp:47
TargetRegistry.h
TargetLoweringObjectFileImpl.h