[ORC] Add std::tuple support to SimplePackedSerialization.
[llvm-project.git] / llvm / lib / Target / CSKY / CSKYTargetMachine.cpp
blob1c13796e84b6ea721904c8a056b713ea38d58a14
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.
11 //===----------------------------------------------------------------------===//
13 #include "CSKYTargetMachine.h"
14 #include "TargetInfo/CSKYTargetInfo.h"
15 #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
16 #include "llvm/CodeGen/TargetPassConfig.h"
17 #include "llvm/Support/TargetRegistry.h"
19 using namespace llvm;
21 extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeCSKYTarget() {
22 RegisterTargetMachine<CSKYTargetMachine> X(getTheCSKYTarget());
25 static std::string computeDataLayout(const Triple &TT) {
26 std::string Ret;
28 // Only support little endian for now.
29 // TODO: Add support for big endian.
30 Ret += "e";
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";
37 return Ret;
40 CSKYTargetMachine::CSKYTargetMachine(const Target &T, const Triple &TT,
41 StringRef CPU, StringRef FS,
42 const TargetOptions &Options,
43 Optional<Reloc::Model> RM,
44 Optional<CodeModel::Model> CM,
45 CodeGenOpt::Level OL, bool JIT)
46 : LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options,
47 RM.getValueOr(Reloc::Static),
48 getEffectiveCodeModel(CM, CodeModel::Small), OL),
49 TLOF(std::make_unique<TargetLoweringObjectFileELF>()) {
50 initAsmInfo();
53 namespace {
54 class CSKYPassConfig : public TargetPassConfig {
55 public:
56 CSKYPassConfig(CSKYTargetMachine &TM, PassManagerBase &PM)
57 : TargetPassConfig(TM, PM) {}
59 CSKYTargetMachine &getCSKYTargetMachine() const {
60 return getTM<CSKYTargetMachine>();
64 } // namespace
66 TargetPassConfig *CSKYTargetMachine::createPassConfig(PassManagerBase &PM) {
67 return new CSKYPassConfig(*this, PM);