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

Unified Diff: src/IceGlobalContext.h

Issue 1775253003: Cache common constants before lowering. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nits. Created 4 years, 9 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
« no previous file with comments | « no previous file | src/IceGlobalContext.cpp » ('j') | src/IceGlobalContext.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceGlobalContext.h
diff --git a/src/IceGlobalContext.h b/src/IceGlobalContext.h
index f01ac856eecb5284f3fcff9eac5f55b0e6351e60..bcfad3fd9077649a95e52e4ab4a912059ee6051b 100644
--- a/src/IceGlobalContext.h
+++ b/src/IceGlobalContext.h
@@ -21,6 +21,7 @@
#include "IceIntrinsics.h"
#include "IceRNG.h"
#include "IceSwitchLowering.h"
+#include "IceTargetLowering.def"
#include "IceThreading.h"
#include "IceTimerTree.h"
#include "IceTypes.h"
@@ -42,6 +43,14 @@ class ConstantPool;
class EmitterWorkItem;
class FuncSigType;
+// Runtime helper function ID's
Jim Stichnoth 2016/03/17 00:14:52 IDs
Karl 2016/03/17 16:40:53 Done.
+enum RuntimeHelperFuncID {
John 2016/03/17 14:31:33 **I think** this should be an inner type (of Globa
Karl 2016/03/17 16:40:53 I agree that this enum should be put in an enclosi
John 2016/03/17 16:57:17 Please, don't add a namespace. Use a class enum in
Karl 2016/03/17 18:54:55 Done.
+#define X(Tag, Name) H_##Tag,
+ RUNTIME_HELPER_FUNCTIONS_TABLE
+#undef X
+ H_Num
+};
+
/// LockedPtr is a way to provide automatically locked access to some object.
template <typename T> class LockedPtr {
LockedPtr() = delete;
@@ -189,11 +198,49 @@ public:
// getConstant*() functions are not const because they might add something to
// the constant pool.
Constant *getConstantInt(Type Ty, int64_t Value);
- Constant *getConstantInt1(int8_t ConstantInt1);
- Constant *getConstantInt8(int8_t ConstantInt8);
- Constant *getConstantInt16(int16_t ConstantInt16);
- Constant *getConstantInt32(int32_t ConstantInt32);
- Constant *getConstantInt64(int64_t ConstantInt64);
+ Constant *getConstantInt1(int8_t ConstantInt1) {
+ ConstantInt1 &= INT8_C(1);
+ switch (ConstantInt1) {
+ case 0:
+ return getConstantZero(IceType_i1);
+ case 1:
+ return ConstantTrue;
+ default:
+ return installConstantInt1(ConstantInt1);
John 2016/03/17 14:31:33 maybe assert here -- anything other than {0, 1} sh
Karl 2016/03/17 16:40:53 Done.
+ }
+ }
+ Constant *getConstantInt8(int8_t ConstantInt8) {
+ switch (ConstantInt8) {
+ case 0:
+ return getConstantZero(IceType_i8);
+ default:
+ return installConstantInt8(ConstantInt8);
+ }
+ }
+ Constant *getConstantInt16(int16_t ConstantInt16) {
+ switch (ConstantInt16) {
+ case 0:
+ return getConstantZero(IceType_i16);
+ default:
+ return installConstantInt16(ConstantInt16);
+ }
+ }
+ Constant *getConstantInt32(int32_t ConstantInt32) {
+ switch (ConstantInt32) {
+ case 0:
+ return getConstantZero(IceType_i32);
+ default:
+ return installConstantInt32(ConstantInt32);
+ }
+ }
+ Constant *getConstantInt64(int64_t ConstantInt64) {
+ switch (ConstantInt64) {
+ case 0:
+ return getConstantZero(IceType_i64);
+ default:
+ return installConstantInt64(ConstantInt64);
+ }
+ }
Constant *getConstantFloat(float Value);
Constant *getConstantDouble(double Value);
/// Returns a symbolic constant.
@@ -205,13 +252,23 @@ public:
/// Returns an undef.
Constant *getConstantUndef(Type Ty);
/// Returns a zero value.
- Constant *getConstantZero(Type Ty);
+ Constant *getConstantZero(Type Ty) {
+ Constant *Zero = ConstZeroForType[Ty];
+ assert(Zero && "Unsupported zero constant");
+ return Zero;
+ }
/// getConstantPool() returns a copy of the constant pool for constants of a
/// given type.
ConstantList getConstantPool(Type Ty);
/// Returns a copy of the list of external symbols.
ConstantList getConstantExternSyms();
/// @}
+ Constant *getRuntimeHelperFunc(RuntimeHelperFuncID FuncID) const {
+ assert(FuncID < H_Num);
+ Constant *Result = RuntimeHelperFunc[FuncID];
+ assert(Result != nullptr && "No such runtime helper function");
+ return Result;
+ }
/// Return a locked pointer to the registered jump tables.
JumpTableDataList getJumpTables();
@@ -524,7 +581,18 @@ private:
/// Indicates if global variable declarations can be disposed of right after
/// lowering.
bool DisposeGlobalVariablesAfterLowering = true;
-
+ Constant *ConstZeroForType[IceType_NUM];
+ Constant *ConstantTrue;
+ // Holds the constants representing each runtime helper function.
+ Constant *RuntimeHelperFunc[H_Num];
+
+ Constant *installConstantZero(Type Ty);
+ Constant *installConstantInt(Type Ty, int64_t Value);
+ Constant *installConstantInt1(int8_t ConstantInt1);
+ Constant *installConstantInt8(int8_t ConstantInt8);
+ Constant *installConstantInt16(int16_t ConstantInt16);
+ Constant *installConstantInt32(int32_t ConstantInt32);
+ Constant *installConstantInt64(int64_t ConstantInt64);
LockedPtr<ArenaAllocator> getAllocator() {
return LockedPtr<ArenaAllocator>(&Allocator, &AllocLock);
}
« no previous file with comments | « no previous file | src/IceGlobalContext.cpp » ('j') | src/IceGlobalContext.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698