Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Unified Diff: src/IceTargetLoweringARM32.cpp

Issue 1581803009: Make RegARM32 a namespace rather than a class. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nits. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/IceRegistersARM32.h ('K') | « src/IceTargetLoweringARM32.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceTargetLoweringARM32.cpp
diff --git a/src/IceTargetLoweringARM32.cpp b/src/IceTargetLoweringARM32.cpp
index 08e26078de5390a26a9e7bf6705311e552420d5d..f408c6e2fcb8d84208b38925ee434d16253322b2 100644
--- a/src/IceTargetLoweringARM32.cpp
+++ b/src/IceTargetLoweringARM32.cpp
@@ -53,13 +53,55 @@ createTargetHeaderLowering(::Ice::GlobalContext *Ctx) {
void staticInit(const ::Ice::ClFlags &Flags) {
::Ice::ARM32::TargetARM32::staticInit(Flags);
}
+
} // end of namespace ARM32
namespace Ice {
namespace ARM32 {
+namespace {
+
+/// SizeOf is used to obtain the size of an initializer list as a constexpr
+/// expression. This is only needed until our C++ library is updated to
+/// C++ 14 -- which defines constexpr members to std::initializer_list.
+class SizeOf {
+ SizeOf(const SizeOf &) = delete;
+ SizeOf &operator=(const SizeOf &) = delete;
+
+public:
+ constexpr SizeOf() : Size(0) {}
+ template <typename... T>
+ explicit constexpr SizeOf(T...)
+ : Size(__length<T...>::value) {}
+ constexpr SizeT size() const { return Size; }
+
+private:
+ template <typename T, typename... U> struct __length {
+ static constexpr std::size_t value = 1 + __length<U...>::value;
+ };
+
+ template <typename T> struct __length<T> {
+ static constexpr std::size_t value = 1;
+ };
+
+ const std::size_t Size;
+};
+
+} // end of anonymous namespace
+
// Defines the RegARM32::Table table with register information.
-constexpr RegARM32::TableType RegARM32::Table[];
+RegARM32::RegTableType RegARM32::RegTable[RegARM32::Reg_NUM] = {
+#define X(val, encode, name, cc_arg, scratch, preserved, stackptr, frameptr, \
+ isGPR, isInt, isI64Pair, isFP32, isFP64, isVec128, alias_init) \
+ { \
+ name, encode, cc_arg, scratch, preserved, stackptr, frameptr, isGPR, \
+ isInt, isI64Pair, isFP32, isFP64, isVec128, \
+ (SizeOf alias_init).size(), alias_init \
Jim Stichnoth 2016/01/15 01:17:15 I assume this trailing backslash alignment will ge
Karl 2016/01/15 16:11:19 Done.
+ } \
+ ,
+ REGARM32_TABLE
+#undef X
+};
namespace {
@@ -246,7 +288,7 @@ void TargetARM32::staticInit(const ClFlags &Flags) {
llvm::SmallBitVector InvalidRegisters(RegARM32::Reg_NUM);
ScratchRegs.resize(RegARM32::Reg_NUM);
for (int i = 0; i < RegARM32::Reg_NUM; ++i) {
- const auto &Entry = RegARM32::Table[i];
+ const auto &Entry = RegARM32::RegTable[i];
IntegerRegisters[i] = Entry.IsInt;
I64PairRegisters[i] = Entry.IsI64Pair;
Float32Registers[i] = Entry.IsFP32;
@@ -1833,7 +1875,7 @@ llvm::SmallBitVector TargetARM32::getRegisterSet(RegSetMask Include,
llvm::SmallBitVector Registers(RegARM32::Reg_NUM);
for (int i = 0; i < RegARM32::Reg_NUM; ++i) {
- const auto &Entry = RegARM32::Table[i];
+ const auto &Entry = RegARM32::RegTable[i];
if (Entry.Scratch && (Include & RegSet_CallerSave))
Registers[i] = true;
if (Entry.Preserved && (Include & RegSet_CalleeSave))
« src/IceRegistersARM32.h ('K') | « src/IceTargetLoweringARM32.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698