Skip to content

Commit 9e268b4

Browse files
committed
[ARM] Consider denormal mode in ARMSubtarget
1 parent d614027 commit 9e268b4

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

llvm/lib/Target/ARM/ARMSubtarget.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,16 @@ ARMFrameLowering *ARMSubtarget::initializeFrameLowering(StringRef CPU,
8888
ARMSubtarget::ARMSubtarget(const Triple &TT, const std::string &CPU,
8989
const std::string &FS,
9090
const ARMBaseTargetMachine &TM, bool IsLittle,
91-
bool MinSize)
91+
bool MinSize, DenormalMode DM)
9292
: ARMGenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS),
9393
UseMulOps(UseFusedMulOps), CPUString(CPU), OptMinSize(MinSize),
94-
IsLittle(IsLittle), TargetTriple(TT), Options(TM.Options), TM(TM),
94+
IsLittle(IsLittle), DM(DM), TargetTriple(TT), Options(TM.Options), TM(TM),
9595
FrameLowering(initializeFrameLowering(CPU, FS)),
9696
// At this point initializeSubtargetDependencies has been called so
9797
// we can query directly.
98-
InstrInfo(isThumb1Only()
99-
? (ARMBaseInstrInfo *)new Thumb1InstrInfo(*this)
100-
: !isThumb()
101-
? (ARMBaseInstrInfo *)new ARMInstrInfo(*this)
102-
: (ARMBaseInstrInfo *)new Thumb2InstrInfo(*this)),
98+
InstrInfo(isThumb1Only() ? (ARMBaseInstrInfo *)new Thumb1InstrInfo(*this)
99+
: !isThumb() ? (ARMBaseInstrInfo *)new ARMInstrInfo(*this)
100+
: (ARMBaseInstrInfo *)new Thumb2InstrInfo(*this)),
103101
TLInfo(TM, *this) {
104102

105103
CallLoweringInfo.reset(new ARMCallLowering(*getTargetLowering()));

llvm/lib/Target/ARM/ARMSubtarget.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ class ARMSubtarget : public ARMGenSubtargetInfo {
186186
/// IsLittle - The target is Little Endian
187187
bool IsLittle;
188188

189+
/// DM - Denormal mode
190+
/// NEON and VFP RunFast mode are not IEEE 754 compliant,
191+
/// use this field to determine whether to generate NEON/VFP
192+
/// instructions in related function.
193+
DenormalMode DM;
194+
189195
/// TargetTriple - What processor and OS we're targeting.
190196
Triple TargetTriple;
191197

@@ -206,7 +212,7 @@ class ARMSubtarget : public ARMGenSubtargetInfo {
206212
///
207213
ARMSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS,
208214
const ARMBaseTargetMachine &TM, bool IsLittle,
209-
bool MinSize = false);
215+
bool MinSize = false, DenormalMode DM = DenormalMode::getIEEE());
210216

211217
/// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
212218
/// that still makes it profitable to inline the call.

llvm/lib/Target/ARM/ARMTargetMachine.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,18 @@ ARMBaseTargetMachine::getSubtargetImpl(const Function &F) const {
229229
if (F.hasMinSize())
230230
Key += "+minsize";
231231

232+
DenormalMode DM = F.getDenormalModeRaw();
233+
if (DM != DenormalMode::getIEEE())
234+
Key += "denormal-fp-math=" + DM.str();
235+
232236
auto &I = SubtargetMap[Key];
233237
if (!I) {
234238
// This needs to be done before we create a new subtarget since any
235239
// creation will depend on the TM and the code generation flags on the
236240
// function that reside in TargetOptions.
237241
resetTargetOptions(F);
238242
I = std::make_unique<ARMSubtarget>(TargetTriple, CPU, FS, *this, isLittle,
239-
F.hasMinSize());
243+
F.hasMinSize(), DM);
240244

241245
if (!I->isThumb() && !I->hasARMOps())
242246
F.getContext().emitError("Function '" + F.getName() + "' uses ARM "

0 commit comments

Comments
 (0)