llvm.org GIT mirror llvm / 415c71b
[Hexagon] Add a target feature to control using small data section git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332292 91177308-0d34-0410-b5e6-96231b3b80d8 Krzysztof Parzyszek 1 year, 5 months ago
4 changed file(s) with 20 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
5353 "Support for new-value jumps", [FeaturePackets]>;
5454 def FeatureNVS: SubtargetFeature<"nvs", "UseNewValueStores", "true",
5555 "Support for new-value stores", [FeaturePackets]>;
56 def FeatureSmallData: SubtargetFeature<"small-data", "UseSmallData", "true",
57 "Allow GP-relative addressing of global variables">;
5658 def FeatureDuplex: SubtargetFeature<"duplex", "EnableDuplex", "true",
5759 "Enable generation of duplex instruction">;
5860 def FeatureReservedR19: SubtargetFeature<"reserved-r19", "ReservedR19",
323325 def : Proc<"hexagonv4", HexagonModelV4,
324326 [ArchV4,
325327 FeatureDuplex, FeatureMemops, FeatureNVJ, FeatureNVS,
326 FeaturePackets]>;
328 FeaturePackets, FeatureSmallData]>;
327329 def : Proc<"hexagonv5", HexagonModelV4,
328330 [ArchV4, ArchV5,
329331 FeatureDuplex, FeatureMemops, FeatureNVJ, FeatureNVS,
330 FeaturePackets]>;
332 FeaturePackets, FeatureSmallData]>;
331333 def : Proc<"hexagonv55", HexagonModelV55,
332334 [ArchV4, ArchV5, ArchV55,
333335 FeatureDuplex, FeatureMemops, FeatureNVJ, FeatureNVS,
334 FeaturePackets]>;
336 FeaturePackets, FeatureSmallData]>;
335337 def : Proc<"hexagonv60", HexagonModelV60,
336338 [ArchV4, ArchV5, ArchV55, ArchV60,
337339 FeatureDuplex, FeatureMemops, FeatureNVJ, FeatureNVS,
338 FeaturePackets]>;
340 FeaturePackets, FeatureSmallData]>;
339341 def : Proc<"hexagonv62", HexagonModelV62,
340342 [ArchV4, ArchV5, ArchV55, ArchV60, ArchV62,
341343 FeatureDuplex, FeatureMemops, FeatureNVJ, FeatureNVS,
342 FeaturePackets]>;
344 FeaturePackets, FeatureSmallData]>;
343345 def : Proc<"hexagonv65", HexagonModelV65,
344346 [ArchV4, ArchV5, ArchV55, ArchV60, ArchV62, ArchV65,
345347 FeatureDuplex, FeatureMemNoShuf, FeatureMemops, FeatureNVJ,
346 FeatureNVS, FeaturePackets]>;
348 FeatureNVS, FeaturePackets, FeatureSmallData]>;
347349
348350 //===----------------------------------------------------------------------===//
349351 // Declare the target which we are implementing
10151015 if (RM == Reloc::Static) {
10161016 SDValue GA = DAG.getTargetGlobalAddress(GV, dl, PtrVT, Offset);
10171017 const GlobalObject *GO = GV->getBaseObject();
1018 if (GO && HLOF.isGlobalInSmallSection(GO, HTM))
1018 if (GO && Subtarget.useSmallData() && HLOF.isGlobalInSmallSection(GO, HTM))
10191019 return DAG.getNode(HexagonISD::CONST32_GP, dl, PtrVT, GA);
10201020 return DAG.getNode(HexagonISD::CONST32, dl, PtrVT, GA);
10211021 }
5959 "Hexagon Split Const32s and Const64s", false, false)
6060
6161 bool HexagonSplitConst32AndConst64::runOnMachineFunction(MachineFunction &Fn) {
62 const HexagonTargetObjectFile &TLOF =
63 *static_cast(
64 Fn.getTarget().getObjFileLowering());
65 if (TLOF.isSmallDataEnabled())
66 return true;
62 auto &HST = Fn.getSubtarget();
63 auto &HTM = static_cast(Fn.getTarget());
64 auto &TLOF = *HTM.getObjFileLowering();
65 if (HST.useSmallData() && TLOF.isSmallDataEnabled())
66 return false;
6767
68 const TargetInstrInfo *TII = Fn.getSubtarget().getInstrInfo();
69 const TargetRegisterInfo *TRI = Fn.getSubtarget().getRegisterInfo();
68 const TargetInstrInfo *TII = HST.getInstrInfo();
69 const TargetRegisterInfo *TRI = HST.getRegisterInfo();
7070
7171 // Loop over all of the basic blocks
7272 for (MachineBasicBlock &B : Fn) {
108108 //===----------------------------------------------------------------------===//
109109 // Public Constructor Functions
110110 //===----------------------------------------------------------------------===//
111
112111 FunctionPass *llvm::createHexagonSplitConst32AndConst64() {
113112 return new HexagonSplitConst32AndConst64();
114113 }
5454 bool UsePackets = false;
5555 bool UseNewValueJumps = false;
5656 bool UseNewValueStores = false;
57 bool UseSmallData = false;
5758
5859 bool HasMemNoShuf = false;
5960 bool EnableDuplex = false;
152153 bool hasV65TOpsOnly() const {
153154 return getHexagonArchVersion() == Hexagon::ArchEnum::V65;
154155 }
156
157 bool useLongCalls() const { return UseLongCalls; }
155158 bool useMemops() const { return UseMemops; }
156159 bool usePackets() const { return UsePackets; }
157160 bool useNewValueJumps() const { return UseNewValueJumps; }
158161 bool useNewValueStores() const { return UseNewValueStores; }
162 bool useSmallData() const { return UseSmallData; }
159163
160164 bool modeIEEERndNear() const { return ModeIEEERndNear; }
161165 bool useHVXOps() const { return HexagonHVXVersion > Hexagon::ArchEnum::V4; }
164168
165169 bool hasMemNoShuf() const { return HasMemNoShuf; }
166170 bool hasReservedR19() const { return ReservedR19; }
167 bool useLongCalls() const { return UseLongCalls; }
168171 bool usePredicatedCalls() const;
169172
170173 bool useBSBScheduling() const { return UseBSBScheduling; }