1 //===-- VETargetMachine.cpp - Define TargetMachine for VE -----------------===// 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 // 10 //===----------------------------------------------------------------------===// 11 12 #include "VETargetMachine.h" 13 #include "VE.h" 14 #include "llvm/Support/TargetRegistry.h" 15 16 using namespace llvm; 17 18 #define DEBUG_TYPE "ve" 19 20 extern "C" void LLVMInitializeVETarget() { 21 // Register the target. 22 RegisterTargetMachine<VETargetMachine> X(getTheVETarget()); 23 } 24 25 static std::string computeDataLayout(const Triple &T) { 26 // Aurora VE is little endian 27 std::string Ret = "e"; 28 29 // Use ELF mangling 30 Ret += "-m:e"; 31 32 // Alignments for 64 bit integers. 33 Ret += "-i64:64"; 34 35 // VE supports 32 bit and 64 bits integer on registers 36 Ret += "-n32:64"; 37 38 // Stack alignment is 64 bits 39 Ret += "-S64"; 40 41 return Ret; 42 } 43 44 static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) { 45 if (!RM.hasValue()) 46 return Reloc::Static; 47 return *RM; 48 } 49 50 /// Create an Aurora VE architecture model 51 VETargetMachine::VETargetMachine( 52 const Target &T, const Triple &TT, StringRef CPU, StringRef FS, 53 const TargetOptions &Options, Optional<Reloc::Model> RM, 54 Optional<CodeModel::Model> CM, CodeGenOpt::Level OL, bool JIT) 55 : LLVMTargetMachine( 56 T, computeDataLayout(TT), TT, CPU, FS, Options, 57 getEffectiveRelocModel(RM), 58 getEffectiveCodeModel(CM, CodeModel::Small), 59 OL) 60 {} 61 62 VETargetMachine::~VETargetMachine() {} 63