Bill Schmidt
2013-Jan-31 15:26 UTC
[LLVMdev] Getting command line options to affect subtarget features
The problem I'm trying to solve: Invoking clang on PowerPC with -fno-altivec has no effect.>From what I've been able to piece together, PPC.td specifies variousCPUs and the processor features available on each. So for example we have: def FeatureAltivec : SubtargetFeature<"altivec","HasAltivec", "true", "Enable Altivec instructions">; def : Processor<"pwr7", G5Itineraries, [DirectivePwr7, FeatureAltivec, FeatureMFOCRF, FeatureFSqrt, FeatureSTFIWX, FeatureISEL, Feature64Bit /*, Feature64BitRegs */]>; During compilation the subtarget class (such as PPCSubtarget) is instantiated with the strings obtained from -mcpu and -mattr. ParseSubtargetFeatures then uses the -mcpu and -mattr values to determine which features to use for code generation. What seems problematic is that -mattr is the only way that the static features of the target processor can be overridden. It seems there must be a way for command-line parameters such as -fno-altivec to be used to override which processor features are exploited. But I can't see immediately how this should work. I don't know whether or how the command line flags from Clang are made available to LLVM for inspection. I'm sure there must be an obvious way to do this, but peeking at code from other targets hasn't enlightened me. Any advice for how I can accomplish this? Thanks! I appreciate any help. Bill -- Bill Schmidt, Ph.D. IBM Advance Toolchain for PowerLinux IBM Linux Technology Center wschmidt at us.ibm.com wschmidt at linux.vnet.ibm.com
Hal Finkel
2013-Jan-31 15:42 UTC
[LLVMdev] Getting command line options to affect subtarget features
----- Original Message -----> From: "Bill Schmidt" <wschmidt at linux.vnet.ibm.com> > To: llvmdev at cs.uiuc.edu > Sent: Thursday, January 31, 2013 9:26:15 AM > Subject: [LLVMdev] Getting command line options to affect subtarget features > > The problem I'm trying to solve: Invoking clang on PowerPC with > -fno-altivec has no effect. > > From what I've been able to piece together, PPC.td specifies various > CPUs and the processor features available on each. So for example we > have: > > def FeatureAltivec : SubtargetFeature<"altivec","HasAltivec", > "true", > "Enable Altivec > instructions">; > > def : Processor<"pwr7", G5Itineraries, > [DirectivePwr7, FeatureAltivec, > FeatureMFOCRF, FeatureFSqrt, FeatureSTFIWX, > FeatureISEL, Feature64Bit /*, Feature64BitRegs > */]>; > > During compilation the subtarget class (such as PPCSubtarget) is > instantiated with the strings obtained from -mcpu and -mattr. > ParseSubtargetFeatures then uses the -mcpu and -mattr values to > determine which features to use for code generation. > > What seems problematic is that -mattr is the only way that the static > features of the target processor can be overridden. > > It seems there must be a way for command-line parameters such as > -fno-altivec to be used to override which processor features are > exploited. But I can't see immediately how this should work. I > don't > know whether or how the command line flags from Clang are made > available > to LLVM for inspection. > > I'm sure there must be an obvious way to do this, but peeking at code > from other targets hasn't enlightened me. Any advice for how I can > accomplish this?Off of the top of my head... Within the current infrastructure, I think that we need to alter the Clang PowerPC toolchain code (Clang::AddPPCTargetArgs in Tools.cpp) to do something like this: if (Args.hasFlag(options::OPT_fno_altivec, options::OPT_faltivec, true)) { CmdArgs.push_back("-backend-option"); CmdArgs.push_back("-mattr=-altivec"); } Why this not done currently I don't know. -Hal> > Thanks! I appreciate any help. > > Bill > > -- > Bill Schmidt, Ph.D. > IBM Advance Toolchain for PowerLinux > IBM Linux Technology Center > wschmidt at us.ibm.com > wschmidt at linux.vnet.ibm.com > > > > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Bill Schmidt
2013-Jan-31 16:17 UTC
[LLVMdev] Getting command line options to affect subtarget features
On Thu, 2013-01-31 at 09:42 -0600, Hal Finkel wrote:> ----- Original Message ----- > > From: "Bill Schmidt" <wschmidt at linux.vnet.ibm.com> > > To: llvmdev at cs.uiuc.edu > > Sent: Thursday, January 31, 2013 9:26:15 AM > > Subject: [LLVMdev] Getting command line options to affect subtarget features > > > > The problem I'm trying to solve: Invoking clang on PowerPC with > > -fno-altivec has no effect. > > > > From what I've been able to piece together, PPC.td specifies various > > CPUs and the processor features available on each. So for example we > > have: > > > > def FeatureAltivec : SubtargetFeature<"altivec","HasAltivec", > > "true", > > "Enable Altivec > > instructions">; > > > > def : Processor<"pwr7", G5Itineraries, > > [DirectivePwr7, FeatureAltivec, > > FeatureMFOCRF, FeatureFSqrt, FeatureSTFIWX, > > FeatureISEL, Feature64Bit /*, Feature64BitRegs > > */]>; > > > > During compilation the subtarget class (such as PPCSubtarget) is > > instantiated with the strings obtained from -mcpu and -mattr. > > ParseSubtargetFeatures then uses the -mcpu and -mattr values to > > determine which features to use for code generation. > > > > What seems problematic is that -mattr is the only way that the static > > features of the target processor can be overridden. > > > > It seems there must be a way for command-line parameters such as > > -fno-altivec to be used to override which processor features are > > exploited. But I can't see immediately how this should work. I > > don't > > know whether or how the command line flags from Clang are made > > available > > to LLVM for inspection. > > > > I'm sure there must be an obvious way to do this, but peeking at code > > from other targets hasn't enlightened me. Any advice for how I can > > accomplish this? > > Off of the top of my head... > > Within the current infrastructure, I think that we need to alter the Clang PowerPC toolchain code (Clang::AddPPCTargetArgs in Tools.cpp) to do something like this: > > if (Args.hasFlag(options::OPT_fno_altivec, options::OPT_faltivec, true)) { > CmdArgs.push_back("-backend-option"); > CmdArgs.push_back("-mattr=-altivec"); > }Perfect, Hal, thanks! That makes good sense. I'll fix this and also bring some of the CPU handling more up-to-date (several missing processors that ought to be in there). Thanks, Bill> > Why this not done currently I don't know. > > -Hal > > > > > Thanks! I appreciate any help. > > > > Bill > > > > -- > > Bill Schmidt, Ph.D. > > IBM Advance Toolchain for PowerLinux > > IBM Linux Technology Center > > wschmidt at us.ibm.com > > wschmidt at linux.vnet.ibm.com > > > > > > > > > > > > > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > >
Reasonably Related Threads
- [LLVMdev] Getting command line options to affect subtarget features
- [LLVMdev] Getting command line options to affect subtarget features
- [LLVMdev] Getting command line options to affect subtarget features
- [LLVMdev] Getting command line options to affect subtarget features
- [LLVMdev] Getting command line options to affect subtarget features