[LLVMdev] How to query for active subtarget features?

Daniel Sanders Daniel.Sanders at imgtec.com
Thu Mar 27 05:54:00 PDT 2014


I'm not aware of a way to obtain defaults from the backend. In the case of your example Clang currently overrides the backend default in all cases and has its own default value. It then uses its own opinion of the ABI to define __mips_n32, etc.

The relevant code is in tools/clang/lib/Basic/Targets.cpp:
  void getDefaultFeatures(llvm::StringMap<bool> &Features) const override {       
    // The backend enables certain ABI's by default according to the              
    // architecture.                                                              
    // Disable both possible defaults so that we don't end up with multiple       
    // ABI's selected and trigger an assertion.                                   
    Features["o32"] = false;                                                      
    Features["n64"] = false;                                                      
                                                                                  
    Features[ABI] = true;                                                         
    Features[CPU] = true;                                                         
  }

> -----Original Message-----
> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu]
> On Behalf Of Kai Nacke
> Sent: 26 March 2014 16:45
> To: llvmdev at cs.uiuc.edu
> Subject: [LLVMdev] How to query for active subtarget features?
> 
> Hi all!
> 
> In my compiler I like to define some identifiers based on subtarget features.
> E.g. for the MIPS platform: if the user wants to compile for
> N32 (-mattr=+n32), then I want to define the identifier MIPS_N32.
> This is the simple case because I can parse the command line. But if the user
> specifies nothing, then the MIPS target defaults to N64. How can I determine
> this default value?
> 
> I think the solution would be if there is a way to enumerate the subtarget
> features which are active right now. Can this be done currently? I found no
> way but I may miss something here.
> 
> Regards,
> Kai
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list