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

Unified Diff: src/IceOperand.h

Issue 1311653003: Add UBSAN build option and fix undefined behaviour errors. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 3 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
Index: src/IceOperand.h
diff --git a/src/IceOperand.h b/src/IceOperand.h
index 9638066ec89f157fde02511aa98edc716fc595e6..fe2c02b9b402bebfe4ed1ca0c36741533eab0c21 100644
--- a/src/IceOperand.h
+++ b/src/IceOperand.h
@@ -8,11 +8,10 @@
//===----------------------------------------------------------------------===//
///
/// \file
-/// This file declares the Operand class and its target-independent
-/// subclasses. The main classes are Variable, which represents an
-/// LLVM variable that is either register- or stack-allocated, and the
-/// Constant hierarchy, which represents integer, floating-point,
-/// and/or symbolic constants.
+/// This file declares the Operand class and its target-independent subclasses.
+/// The main classes are Variable, which represents an LLVM variable that is
+/// either register- or stack-allocated, and the Constant hierarchy, which
+/// represents integer, floating-point, and/or symbolic constants.
///
//===----------------------------------------------------------------------===//
@@ -22,6 +21,7 @@
#include "IceCfg.h"
#include "IceDefs.h"
#include "IceGlobalContext.h"
+#include "IceTargetKinds.def"
#include "IceTypes.h"
namespace Ice {
@@ -32,7 +32,6 @@ class Operand {
Operand &operator=(const Operand &) = delete;
public:
- static const size_t MaxTargetKinds = 10;
enum OperandKind {
kConst_Base,
kConstInteger32,
@@ -41,25 +40,30 @@ public:
kConstDouble,
kConstRelocatable,
kConstUndef,
- kConst_Target, // leave space for target-specific constant kinds
- kConst_Num = kConst_Target + MaxTargetKinds,
+#define X(n) kConst_Target##n,
+ TARGETKINDS_TABLE
+#undef X
+ kConst_Max = kConst_Target0 + TARGETKINDS_TABLE_MAX,
kVariable,
- kVariable_Target, // leave space for target-specific variable kinds
- kVariable_Num = kVariable_Target + MaxTargetKinds,
+#define X(n) kVariable_Target##n,
+ TARGETKINDS_TABLE
+#undef X
+ kVariable_Max = kVariable_Target0 + TARGETKINDS_TABLE_MAX,
// Target-specific operand classes use kTarget as the starting
// point for their Kind enum space. Note that the value-spaces are shared
// across targets. To avoid confusion over the definition of shared
// values, an object specific to one target should never be passed
// to a different target.
- kTarget
+#define X(n) kTarget##n,
+ TARGETKINDS_TABLE
+#undef X
};
OperandKind getKind() const { return Kind; }
Type getType() const { return Ty; }
- /// Every Operand keeps an array of the Variables referenced in
- /// the operand. This is so that the liveness operations can get
- /// quick access to the variables of interest, without having to dig
- /// so far into the operand.
+ /// Every Operand keeps an array of the Variables referenced in the operand.
+ /// This is so that the liveness operations can get quick access to the
+ /// variables of interest, without having to dig so far into the operand.
SizeT getNumVars() const { return NumVars; }
Variable *getVar(SizeT I) const {
assert(I < getNumVars());
@@ -118,7 +122,7 @@ public:
static bool classof(const Operand *Operand) {
OperandKind Kind = Operand->getKind();
- return Kind >= kConst_Base && Kind <= kConst_Num;
+ return Kind >= kConst_Base && Kind <= kConst_Max;
}
/// Judge if this given immediate should be randomized or pooled
@@ -508,7 +512,7 @@ public:
static bool classof(const Operand *Operand) {
OperandKind Kind = Operand->getKind();
- return Kind >= kVariable && Kind <= kVariable_Num;
+ return Kind >= kVariable && Kind <= kVariable_Max;
}
protected:
« src/IceInst.h ('K') | « src/IceInstX86Base.h ('k') | src/IceTargetKinds.def » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698