MCCodeGenInfo *createARM64MCCodeGenInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { Triple TheTriple(TT); MCCodeGenInfo *X = new MCCodeGenInfo(); if (TheTriple.isOSDarwin()) { // ARM64 Darwin is always PIC. X->InitMCCodeGenInfo(Reloc::PIC_, CM, OL); return X; } assert(TheTriple.isOSBinFormatELF() && "Only expect Darwin and ELF targets"); if (RM == Reloc::Default || RM == Reloc::DynamicNoPIC) { // On ELF platforms the default static relocation model has a smart enough // linker to cope with referencing external symbols defined in a shared // library. Hence DynamicNoPIC doesn't need to be promoted to PIC. RM = Reloc::Static; } if (CM == CodeModel::Default) CM = CodeModel::Small; else if (CM == CodeModel::JITDefault) { // The default MCJIT memory managers make no guarantees about where they can // find an executable page; JITed code needs to be able to refer to globals // no matter how far away they are. CM = CodeModel::Large; } X->InitMCCodeGenInfo(RM, CM, OL); return X; }
static MCCodeGenInfo *createPTXMCCodeGenInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { MCCodeGenInfo *X = new MCCodeGenInfo(); X->InitMCCodeGenInfo(RM, CM, OL); return X; }
static MCCodeGenInfo *createLanaiMCCodeGenInfo(const Triple &TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { MCCodeGenInfo *X = new MCCodeGenInfo(); X->initMCCodeGenInfo(RM, CM, OL); return X; }
static MCCodeGenInfo *createNVPTXMCCodeGenInfo( StringRef TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { MCCodeGenInfo *X = new MCCodeGenInfo(); // The default relocation model is used regardless of what the client has // specified, as it is the only relocation model currently supported. X->initMCCodeGenInfo(Reloc::Default, CM, OL); return X; }
static MCCodeGenInfo *createEpiphanyMCCodeGenInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { MCCodeGenInfo *X = new MCCodeGenInfo(); RM = Reloc::Static; CM = CodeModel::Small; X->InitMCCodeGenInfo(RM, CM, OL); return X; }
static MCCodeGenInfo *createHexagonMCCodeGenInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { MCCodeGenInfo *X = new MCCodeGenInfo(); // For the time being, use static relocations, since there's really no // support for PIC yet. X->InitMCCodeGenInfo(Reloc::Static, CM, OL); return X; }
static MCCodeGenInfo *createMipsMCCodeGenInfo(const Triple &TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { MCCodeGenInfo *X = new MCCodeGenInfo(); if (RM == Reloc::Default || CM == CodeModel::JITDefault) RM = Reloc::Static; X->initMCCodeGenInfo(RM, CM, OL); return X; }
static MCCodeGenInfo *createMipsMCCodeGenInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { MCCodeGenInfo *X = new MCCodeGenInfo(); if (RM == Reloc::Default) RM = Reloc::PIC_; X->InitMCCodeGenInfo(RM, CM, OL); return X; }
static MCCodeGenInfo *createXCoreMCCodeGenInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { MCCodeGenInfo *X = new MCCodeGenInfo(); if (RM == Reloc::Default) { RM = Reloc::Static; } X->InitMCCodeGenInfo(RM, CM, OL); return X; }
static MCCodeGenInfo *createMBlazeMCCodeGenInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { MCCodeGenInfo *X = new MCCodeGenInfo(); if (RM == Reloc::Default) RM = Reloc::Static; if (CM == CodeModel::Default) CM = CodeModel::Small; X->InitMCCodeGenInfo(RM, CM, OL); return X; }
static MCCodeGenInfo *createARMMCCodeGenInfo(const Triple &TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { MCCodeGenInfo *X = new MCCodeGenInfo(); if (RM == Reloc::Default) { // Default relocation model on Darwin is PIC, not DynamicNoPIC. RM = TT.isOSDarwin() ? Reloc::PIC_ : Reloc::DynamicNoPIC; } X->initMCCodeGenInfo(RM, CM, OL); return X; }
static MCCodeGenInfo *createCpu0MCCodeGenInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { MCCodeGenInfo *X = new MCCodeGenInfo(); if (CM == CodeModel::JITDefault) RM = Reloc::Static; else if (RM == Reloc::Default) RM = Reloc::PIC_; X->InitMCCodeGenInfo(RM, CM, OL); // defined in lib/MC/MCCodeGenInfo.cpp return X; }
static MCCodeGenInfo *createSparcMCCodeGenInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { MCCodeGenInfo *X = new MCCodeGenInfo(); // The default 32-bit code model is abs32/pic32. if (CM == CodeModel::Default) CM = RM == Reloc::PIC_ ? CodeModel::Medium : CodeModel::Small; X->InitMCCodeGenInfo(RM, CM, OL); return X; }
static MCCodeGenInfo *createARMMCCodeGenInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { MCCodeGenInfo *X = new MCCodeGenInfo(); if (RM == Reloc::Default) { Triple TheTriple(TT); // Default relocation model on Darwin is PIC, not DynamicNoPIC. RM = TheTriple.isOSDarwin() ? Reloc::PIC_ : Reloc::DynamicNoPIC; } X->InitMCCodeGenInfo(RM, CM, OL); return X; }
static MCCodeGenInfo *createSparcV9MCCodeGenInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { MCCodeGenInfo *X = new MCCodeGenInfo(); // The default 64-bit code model is abs44/pic32. if (CM == CodeModel::Default) CM = CodeModel::Medium; X->InitMCCodeGenInfo(RM, CM, OL); return X; }
static MCCodeGenInfo *createMipsMCCodeGenInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM) { MCCodeGenInfo *X = new MCCodeGenInfo(); if (RM == Reloc::Default) { // Abicall enables PIC by default if (TT.find("mipsallegrex") != std::string::npos || TT.find("psp") != std::string::npos) RM = Reloc::Static; else RM = Reloc::PIC_; } X->InitMCCodeGenInfo(RM, CM); return X; }
static MCCodeGenInfo *createX86MCCodeGenInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { MCCodeGenInfo *X = new MCCodeGenInfo(); Triple T(TT); bool is64Bit = T.getArch() == Triple::x86_64; if (RM == Reloc::Default) { // Darwin defaults to PIC in 64 bit mode and dynamic-no-pic in 32 bit mode. // Win64 requires rip-rel addressing, thus we force it to PIC. Otherwise we // use static relocation model by default. if (T.isOSDarwin()) { if (is64Bit) RM = Reloc::PIC_; else RM = Reloc::DynamicNoPIC; } else if (T.isOSWindows() && is64Bit) RM = Reloc::PIC_; else RM = Reloc::Static; } // ELF and X86-64 don't have a distinct DynamicNoPIC model. DynamicNoPIC // is defined as a model for code which may be used in static or dynamic // executables but not necessarily a shared library. On X86-32 we just // compile in -static mode, in x86-64 we use PIC. if (RM == Reloc::DynamicNoPIC) { if (is64Bit) RM = Reloc::PIC_; else if (!T.isOSDarwin()) RM = Reloc::Static; } // If we are on Darwin, disallow static relocation model in X86-64 mode, since // the Mach-O file format doesn't support it. if (RM == Reloc::Static && T.isOSDarwin() && is64Bit) RM = Reloc::PIC_; // For static codegen, if we're not already set, use Small codegen. if (CM == CodeModel::Default) CM = CodeModel::Small; else if (CM == CodeModel::JITDefault) // 64-bit JIT places everything in the same buffer except external funcs. CM = is64Bit ? CodeModel::Large : CodeModel::Small; X->initMCCodeGenInfo(RM, CM, OL); return X; }
static MCCodeGenInfo *createPPCMCCodeGenInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { MCCodeGenInfo *X = new MCCodeGenInfo(); if (RM == Reloc::Default) { Triple T(TT); if (T.isOSDarwin()) RM = Reloc::DynamicNoPIC; else RM = Reloc::Static; } X->InitMCCodeGenInfo(RM, CM, OL); return X; }
static MCCodeGenInfo *createXCoreMCCodeGenInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { MCCodeGenInfo *X = new MCCodeGenInfo(); if (RM == Reloc::Default) { RM = Reloc::Static; } if (CM == CodeModel::Default) { CM = CodeModel::Small; } if (CM != CodeModel::Small && CM != CodeModel::Large) report_fatal_error("Target only supports CodeModel Small or Large"); X->initMCCodeGenInfo(RM, CM, OL); return X; }
static MCCodeGenInfo *createSystemZMCCodeGenInfo(const Triple &TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { MCCodeGenInfo *X = new MCCodeGenInfo(); // Static code is suitable for use in a dynamic executable; there is no // separate DynamicNoPIC model. if (RM == Reloc::Default || RM == Reloc::DynamicNoPIC) RM = Reloc::Static; // For SystemZ we define the models as follows: // // Small: BRASL can call any function and will use a stub if necessary. // Locally-binding symbols will always be in range of LARL. // // Medium: BRASL can call any function and will use a stub if necessary. // GOT slots and locally-defined text will always be in range // of LARL, but other symbols might not be. // // Large: Equivalent to Medium for now. // // Kernel: Equivalent to Medium for now. // // This means that any PIC module smaller than 4GB meets the // requirements of Small, so Small seems like the best default there. // // All symbols bind locally in a non-PIC module, so the choice is less // obvious. There are two cases: // // - When creating an executable, PLTs and copy relocations allow // us to treat external symbols as part of the executable. // Any executable smaller than 4GB meets the requirements of Small, // so that seems like the best default. // // - When creating JIT code, stubs will be in range of BRASL if the // image is less than 4GB in size. GOT entries will likewise be // in range of LARL. However, the JIT environment has no equivalent // of copy relocs, so locally-binding data symbols might not be in // the range of LARL. We need the Medium model in that case. if (CM == CodeModel::Default) CM = CodeModel::Small; else if (CM == CodeModel::JITDefault) CM = RM == Reloc::PIC_ ? CodeModel::Small : CodeModel::Medium; X->initMCCodeGenInfo(RM, CM, OL); return X; }
static MCCodeGenInfo *createPPCMCCodeGenInfo(const Triple &TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { MCCodeGenInfo *X = new MCCodeGenInfo(); if (RM == Reloc::Default) { if (TT.isOSDarwin()) RM = Reloc::DynamicNoPIC; else RM = Reloc::Static; } if (CM == CodeModel::Default) { if (!TT.isOSDarwin() && (TT.getArch() == Triple::ppc64 || TT.getArch() == Triple::ppc64le)) CM = CodeModel::Medium; } X->initMCCodeGenInfo(RM, CM, OL); return X; }
static MCCodeGenInfo *createAArch64MCCodeGenInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { MCCodeGenInfo *X = new MCCodeGenInfo(); if (RM == Reloc::Default || RM == Reloc::DynamicNoPIC) { // On ELF platforms the default static relocation model has a smart enough // linker to cope with referencing external symbols defined in a shared // library. Hence DynamicNoPIC doesn't need to be promoted to PIC. RM = Reloc::Static; } if (CM == CodeModel::Default) CM = CodeModel::Small; else if (CM == CodeModel::JITDefault) { // The default MCJIT memory managers make no guarantees about where they can // find an executable page; JITed code needs to be able to refer to globals // no matter how far away they are. CM = CodeModel::Large; } X->InitMCCodeGenInfo(RM, CM, OL); return X; }
static MCCodeGenInfo *createSparcMCCodeGenInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM) { MCCodeGenInfo *X = new MCCodeGenInfo(); X->InitMCCodeGenInfo(RM, CM); return X; }