[llvm] r218652 - [FastISel][AArch64] Factor out scale factor calculation. NFC.
Juergen Ributzka
juergen at apple.com
Mon Sep 29 17:49:54 PDT 2014
Author: ributzka
Date: Mon Sep 29 19:49:54 2014
New Revision: 218652
URL: http://llvm.org/viewvc/llvm-project?rev=218652&view=rev
Log:
[FastISel][AArch64] Factor out scale factor calculation. NFC.
Factor out the code that determines the implicit scale factor of memory
operations for a given value type.
Modified:
llvm/trunk/lib/Target/AArch64/AArch64FastISel.cpp
Modified: llvm/trunk/lib/Target/AArch64/AArch64FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64FastISel.cpp?rev=218652&r1=218651&r2=218652&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64FastISel.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64FastISel.cpp Mon Sep 29 19:49:54 2014
@@ -255,6 +255,26 @@ public:
#include "AArch64GenCallingConv.inc"
+/// \brief Determine the implicit scale factor that is applied by a memory
+/// operation for a given value type.
+static unsigned getImplicitScaleFactor(MVT VT) {
+ switch (VT.SimpleTy) {
+ default:
+ return 0; // invalid
+ case MVT::i1: // fall-through
+ case MVT::i8:
+ return 1;
+ case MVT::i16:
+ return 2;
+ case MVT::i32: // fall-through
+ case MVT::f32:
+ return 4;
+ case MVT::i64: // fall-through
+ case MVT::f64:
+ return 8;
+ }
+}
+
CCAssignFn *AArch64FastISel::CCAssignFnForCall(CallingConv::ID CC) const {
if (CC == CallingConv::WebKit_JS)
return CC_AArch64_WebKit_JS;
@@ -839,17 +859,9 @@ bool AArch64FastISel::isValueAvailable(c
}
bool AArch64FastISel::simplifyAddress(Address &Addr, MVT VT) {
- unsigned ScaleFactor;
- switch (VT.SimpleTy) {
- default: return false;
- case MVT::i1: // fall-through
- case MVT::i8: ScaleFactor = 1; break;
- case MVT::i16: ScaleFactor = 2; break;
- case MVT::i32: // fall-through
- case MVT::f32: ScaleFactor = 4; break;
- case MVT::i64: // fall-through
- case MVT::f64: ScaleFactor = 8; break;
- }
+ unsigned ScaleFactor = getImplicitScaleFactor(VT);
+ if (!ScaleFactor)
+ return false;
bool ImmediateOffsetNeedsLowering = false;
bool RegisterOffsetNeedsLowering = false;
@@ -1561,17 +1573,9 @@ bool AArch64FastISel::emitLoad(MVT VT, u
if (!simplifyAddress(Addr, VT))
return false;
- unsigned ScaleFactor;
- switch (VT.SimpleTy) {
- default: llvm_unreachable("Unexpected value type.");
- case MVT::i1: // fall-through
- case MVT::i8: ScaleFactor = 1; break;
- case MVT::i16: ScaleFactor = 2; break;
- case MVT::i32: // fall-through
- case MVT::f32: ScaleFactor = 4; break;
- case MVT::i64: // fall-through
- case MVT::f64: ScaleFactor = 8; break;
- }
+ unsigned ScaleFactor = getImplicitScaleFactor(VT);
+ if (!ScaleFactor)
+ llvm_unreachable("Unexpected value type.");
// Negative offsets require unscaled, 9-bit, signed immediate offsets.
// Otherwise, we try using scaled, 12-bit, unsigned immediate offsets.
@@ -1711,17 +1715,9 @@ bool AArch64FastISel::emitStore(MVT VT,
if (!simplifyAddress(Addr, VT))
return false;
- unsigned ScaleFactor;
- switch (VT.SimpleTy) {
- default: llvm_unreachable("Unexpected value type.");
- case MVT::i1: // fall-through
- case MVT::i8: ScaleFactor = 1; break;
- case MVT::i16: ScaleFactor = 2; break;
- case MVT::i32: // fall-through
- case MVT::f32: ScaleFactor = 4; break;
- case MVT::i64: // fall-through
- case MVT::f64: ScaleFactor = 8; break;
- }
+ unsigned ScaleFactor = getImplicitScaleFactor(VT);
+ if (!ScaleFactor)
+ llvm_unreachable("Unexpected value type.");
// Negative offsets require unscaled, 9-bit, signed immediate offsets.
// Otherwise, we try using scaled, 12-bit, unsigned immediate offsets.
@@ -1731,7 +1727,6 @@ bool AArch64FastISel::emitStore(MVT VT,
ScaleFactor = 1;
}
-
static const unsigned OpcTable[4][6] = {
{ AArch64::STURBBi, AArch64::STURHHi, AArch64::STURWi, AArch64::STURXi,
AArch64::STURSi, AArch64::STURDi },
@@ -1741,7 +1736,6 @@ bool AArch64FastISel::emitStore(MVT VT,
AArch64::STRSroX, AArch64::STRDroX },
{ AArch64::STRBBroW, AArch64::STRHHroW, AArch64::STRWroW, AArch64::STRXroW,
AArch64::STRSroW, AArch64::STRDroW }
-
};
unsigned Opc;
More information about the llvm-commits
mailing list