Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

Changeset 699:ed9a9e6dd1cc

Show
Ignore:
Timestamp:
10/13/08 11:28:39 (3 months ago)
Author:
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
branch:
default
Message:

Started changing target triple stuff, part of fixing #97

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dmd/mars.c

    r695 r699  
    830830        global.params.is64bit = false; 
    831831        global.params.cpu = ARCHx86; 
    832         global.params.tt_arch = "i686"; 
    833         global.params.data_layout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-f80:32:32-v64:64:64-v128:128:128-a0:0:64"; 
     832        //global.params.data_layout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-f80:32:32-v64:64:64-v128:128:128-a0:0:64"; 
    834833        if (global.params.useInlineAsm) { 
    835834            VersionCondition::addPredefinedGlobalIdent("LLVM_InlineAsm_X86"); 
     
    841840        global.params.is64bit = true; 
    842841        global.params.cpu = ARCHx86_64; 
    843         global.params.tt_arch = "x86_64"; 
    844         global.params.data_layout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64"; 
     842        //global.params.data_layout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64"; 
    845843    } 
    846844    else if (strcmp(global.params.llvmArch,"ppc32")==0) { 
     
    849847        global.params.is64bit = false; 
    850848        global.params.cpu = ARCHppc; 
    851         global.params.tt_arch = "powerpc"; 
    852         global.params.data_layout = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64"; 
     849        //global.params.data_layout = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64"; 
    853850    } 
    854851    else if (strcmp(global.params.llvmArch,"ppc64")==0) { 
     
    857854        global.params.is64bit = true; 
    858855        global.params.cpu = ARCHppc_64; 
    859         global.params.tt_arch = "powerpc64"; 
    860         global.params.data_layout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64"; 
     856        //global.params.data_layout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64"; 
    861857    } 
    862858    else { 
     
    889885    VersionCondition::addPredefinedGlobalIdent("Win32"); 
    890886    VersionCondition::addPredefinedGlobalIdent("mingw32"); 
    891     global.params.tt_os = "-pc-mingw32"; 
    892887    break; 
    893888 
     
    895890    VersionCondition::addPredefinedGlobalIdent("linux"); 
    896891    VersionCondition::addPredefinedGlobalIdent("Posix"); 
    897     global.params.tt_os = "-pc-linux-gnu"; 
    898892    break; 
    899893 
     
    901895    VersionCondition::addPredefinedGlobalIdent("darwin"); 
    902896    VersionCondition::addPredefinedGlobalIdent("Posix"); 
    903     global.params.tt_os = "-pc-darwin-gnu"; 
    904897    break; 
    905898 
     
    913906    } 
    914907 
     908    if (!global.params.targetTriple) 
     909        global.params.targetTriple = DEFAULT_TARGET_TRIPLE; 
     910 
     911    Logger::println("Target triple: %s", global.params.targetTriple); 
    915912 
    916913    // Initialization 
  • dmd/mars.h

    r694 r699  
    143143    char *llvmArch; 
    144144    char forceBE; 
    145     char *tt_arch; 
    146     char *tt_os; 
    147     char *data_layout; 
    148145    char output_ll; 
    149146    char output_bc; 
     
    155152    char fqnNames; // use fully qualified object names 
    156153    char noDefaultLib; 
     154 
     155    // target stuff 
     156    char *targetTriple; 
    157157}; 
    158158 
  • gen/toir.cpp

    r682 r699  
    472472        return newlen; 
    473473    } 
     474    else if (e1->op == TOKslice && !ismemset && 
     475        (e2->op == TOKadd || e2->op == TOKmin || 
     476        e2->op == TOKmul || e2->op == TOKdiv || 
     477        e2->op == TOKmod || e2->op == TOKxor || 
     478        e2->op == TOKand || e2->op == TOKor  || 
     479        e2->op == TOKtilde || e2->op == TOKneg)) 
     480    { 
     481        assert(0 && "array op assignment is TODO"); 
     482    } 
    474483 
    475484    Logger::println("performing normal assignment"); 
     
    482491        return l; 
    483492 
    484 #if 0 
    485     if (type->toBasetype()->ty == Tstruct && e2->type->isintegral()) 
    486     {  
    487         // handle struct = 0;  
    488         return l;  
    489     }  
    490     else  
    491     {  
    492         return r; 
    493     } 
    494 #else 
    495493    return r; 
    496 #endif 
    497494} 
    498495 
  • gen/toobj.cpp

    r694 r699  
    6060 
    6161// fwd decl 
    62 void write_asm_to_file(llvm::Module& m, llvm::raw_fd_ostream& Out); 
     62void write_asm_to_file(llvm::TargetMachine &Target, llvm::Module& m, llvm::raw_fd_ostream& Out); 
    6363void assemble(const llvm::sys::Path& asmpath, const llvm::sys::Path& objpath, char** envp); 
    6464 
     
    103103 
    104104    // set target stuff 
    105     std::string target_triple(global.params.tt_arch); 
    106     target_triple.append(global.params.tt_os); 
    107     ir.module->setTargetTriple(target_triple); 
    108     ir.module->setDataLayout(global.params.data_layout); 
    109  
    110     gTargetData = new llvm::TargetData(global.params.data_layout); 
     105 
     106    ir.module->setTargetTriple(global.params.targetTriple); 
     107 
     108    // get the target machine 
     109    const llvm::TargetMachineRegistry::entry* MArch; 
     110 
     111    std::string Err; 
     112    MArch = llvm::TargetMachineRegistry::getClosestStaticTargetForModule(*ir.module, Err); 
     113    if (MArch == 0) { 
     114        error("error auto-selecting target for module '%s'", Err.c_str()); 
     115        fatal(); 
     116    } 
     117 
     118    llvm::SubtargetFeatures Features; 
     119//TODO: Features? 
     120//    Features.setCPU(MCPU); 
     121//    for (unsigned i = 0; i != MAttrs.size(); ++i) 
     122//      Features.AddFeature(MAttrs[i]); 
     123 
     124    // only generate PIC code when -fPIC switch is used 
     125    if (global.params.pic) 
     126        llvm::TargetMachine::setRelocationModel(llvm::Reloc::PIC_); 
     127 
     128    // allocate the target machine 
     129    std::auto_ptr<llvm::TargetMachine> target(MArch->CtorFn(*ir.module, Features.getString())); 
     130    assert(target.get() && "Could not allocate target machine!"); 
     131    llvm::TargetMachine &Target = *target.get(); 
     132 
     133    gTargetData = Target.getTargetData(); 
     134    ir.module->setDataLayout(gTargetData->getStringRepresentation()); 
    111135 
    112136    // debug info 
     
    223247        { 
    224248            llvm::raw_fd_ostream out(spath.c_str(), err); 
    225             write_asm_to_file(*ir.module, out); 
     249            write_asm_to_file(Target, *ir.module, out); 
    226250        } 
    227251 
     
    252276 
    253277// based on llc code, University of Illinois Open Source License 
    254 void write_asm_to_file(llvm::Module& m, llvm::raw_fd_ostream& out) 
     278void write_asm_to_file(llvm::TargetMachine &Target, llvm::Module& m, llvm::raw_fd_ostream& out) 
    255279{ 
    256280    using namespace llvm; 
    257  
    258     std::string Err; 
    259  
    260     const TargetMachineRegistry::entry* MArch; 
    261     MArch = TargetMachineRegistry::getClosestStaticTargetForModule(m, Err); 
    262     if (MArch == 0) { 
    263         error("error auto-selecting target for module '%s'", Err.c_str()); 
    264         fatal(); 
    265     } 
    266  
    267     SubtargetFeatures Features; 
    268 //TODO: Features? 
    269 //    Features.setCPU(MCPU); 
    270 //    for (unsigned i = 0; i != MAttrs.size(); ++i) 
    271 //      Features.AddFeature(MAttrs[i]); 
    272  
    273     //FIXME: Only set this if required? 
    274     TargetMachine::setRelocationModel(Reloc::PIC_); 
    275  
    276     std::auto_ptr<TargetMachine> target(MArch->CtorFn(m, Features.getString())); 
    277     assert(target.get() && "Could not allocate target machine!"); 
    278     TargetMachine &Target = *target.get(); 
    279281 
    280282    // Build up all of the passes that we want to do to the module. 
    281283    ExistingModuleProvider Provider(&m); 
    282284    FunctionPassManager Passes(&Provider); 
    283     //FIXME: Will gTargetData always be Target.getTargetData anyway? 
    284     assert(gTargetData->getStringRepresentation() == Target.getTargetData()->getStringRepresentation()); 
     285 
    285286    Passes.add(new TargetData(*Target.getTargetData())); 
    286287 
     
    306307 
    307308    // release module from module provider so we can delete it ourselves 
     309    std::string Err; 
    308310    llvm::Module* rmod = Provider.releaseModule(&Err); 
    309311    assert(rmod); 
  • premake.lua

    r673 r699  
    2020if OS == "windows" then 
    2121    POSIX = 0 
     22end 
     23 
     24 
     25-- guess the host machine description 
     26-- also allow overriding it 
     27 
     28addoption("target-override", "Override the default target machine"); 
     29 
     30TRIPLE = ""; 
     31if options["target-override"] then 
     32    TRIPLE = options["target-override"] 
     33else 
     34    local p = io.popen("./config.guess") 
     35    TRIPLE = p:read() 
    2236end 
    2337 
     
    6680    "DMDV1="..DMDV1, 
    6781    "POSIX="..POSIX, 
     82    "DEFAULT_TARGET_TRIPLE=\\\""..TRIPLE.."\\\"", 
    6883} 
    6984package.config.Release.defines = { "LLVMD_NO_LOGGER" } 
Copyright © 2008, LDC Development Team.