Index: src/IceTargetLowering.h |
diff --git a/src/IceTargetLowering.h b/src/IceTargetLowering.h |
index 86721a20dd87012c94e5091c2c3d98a866dc345f..2acc39439772e65d6ad731915b89d3507fee4f44 100644 |
--- a/src/IceTargetLowering.h |
+++ b/src/IceTargetLowering.h |
@@ -28,6 +28,7 @@ |
#include "IceCfgNode.h" |
#include "IceInst.h" // for the names of the Inst subtypes |
#include "IceOperand.h" |
+#include "IceTargetLowering.def" |
#include "IceTypes.h" |
#include <utility> |
@@ -461,8 +462,15 @@ protected: |
/// with the largest alignment need are placed in the front of the Dest list. |
void sortVarsByAlignment(VarList &Dest, const VarList &Source) const; |
- /// Make a call to an external helper function. |
- InstCall *makeHelperCall(const IceString &Name, Variable *Dest, |
+ // Runtime helper function names |
Karl
2016/03/16 22:50:52
Also moved this enum to global context, so that we
|
+ enum RuntimeHelperFuncKind { |
+#define X(Tag, Name) H_##Tag, |
+ RUNTIME_HELPER_FUNCTIONS_TABLE |
+#undef X |
+ H_Num |
+ }; |
+ |
+ InstCall *makeHelperCall(RuntimeHelperFuncKind Target, Variable *Dest, |
SizeT MaxSrcs); |
void _set_dest_redefined() { Context.getLastInserted()->setDestRedefined(); } |
@@ -569,44 +577,29 @@ protected: |
LoweringContext Context; |
const SandboxType SandboxingType = ST_None; |
- // Runtime helper function names |
- const static constexpr char *H_bitcast_16xi1_i16 = "__Sz_bitcast_16xi1_i16"; |
- const static constexpr char *H_bitcast_8xi1_i8 = "__Sz_bitcast_8xi1_i8"; |
- const static constexpr char *H_bitcast_i16_16xi1 = "__Sz_bitcast_i16_16xi1"; |
- const static constexpr char *H_bitcast_i8_8xi1 = "__Sz_bitcast_i8_8xi1"; |
- const static constexpr char *H_call_ctpop_i32 = "__popcountsi2"; |
- const static constexpr char *H_call_ctpop_i64 = "__popcountdi2"; |
- const static constexpr char *H_call_longjmp = "longjmp"; |
- const static constexpr char *H_call_memcpy = "memcpy"; |
- const static constexpr char *H_call_memmove = "memmove"; |
- const static constexpr char *H_call_memset = "memset"; |
- const static constexpr char *H_call_read_tp = "__nacl_read_tp"; |
- const static constexpr char *H_call_setjmp = "setjmp"; |
- const static constexpr char *H_fptosi_f32_i64 = "__Sz_fptosi_f32_i64"; |
- const static constexpr char *H_fptosi_f64_i64 = "__Sz_fptosi_f64_i64"; |
- const static constexpr char *H_fptoui_4xi32_f32 = "__Sz_fptoui_4xi32_f32"; |
- const static constexpr char *H_fptoui_f32_i32 = "__Sz_fptoui_f32_i32"; |
- const static constexpr char *H_fptoui_f32_i64 = "__Sz_fptoui_f32_i64"; |
- const static constexpr char *H_fptoui_f64_i32 = "__Sz_fptoui_f64_i32"; |
- const static constexpr char *H_fptoui_f64_i64 = "__Sz_fptoui_f64_i64"; |
- const static constexpr char *H_frem_f32 = "fmodf"; |
- const static constexpr char *H_frem_f64 = "fmod"; |
+ /// Returns constant zero of Ty. |
Jim Stichnoth
2016/03/10 00:24:46
You should probably also try to capture the calls
Karl
2016/03/16 22:50:52
The plan was to capture more constants. This CL wa
|
+ Constant *getConstantZero(Type Ty) const { |
+ assert(Ty < IceType_NUM); |
+ if (Constant *Result = ConstZeroForType[Ty]) |
+ return Result; |
+ return Ctx->getConstantZero(Ty); |
+ } |
+ |
+ /// Returns the constant defining the corresponding runtime helper function. |
+ Constant *getRuntimeHelperFunc(RuntimeHelperFuncKind Kind) const { |
Karl
2016/03/16 22:50:52
Moved this to global context, and modified body (h
|
+ assert(Kind < H_Num); |
+ Constant *Result = RuntimeHelperFunc[Kind]; |
+ assert(Result != nullptr && "No such runtime helper function"); |
+ return Result; |
+ } |
+ |
const static constexpr char *H_getIP_prefix = "__Sz_getIP_"; |
- const static constexpr char *H_sdiv_i32 = "__divsi3"; |
- const static constexpr char *H_sdiv_i64 = "__divdi3"; |
- const static constexpr char *H_sitofp_i64_f32 = "__Sz_sitofp_i64_f32"; |
- const static constexpr char *H_sitofp_i64_f64 = "__Sz_sitofp_i64_f64"; |
- const static constexpr char *H_srem_i32 = "__modsi3"; |
- const static constexpr char *H_srem_i64 = "__moddi3"; |
- const static constexpr char *H_udiv_i32 = "__udivsi3"; |
- const static constexpr char *H_udiv_i64 = "__udivdi3"; |
- const static constexpr char *H_uitofp_4xi32_4xf32 = "__Sz_uitofp_4xi32_4xf32"; |
- const static constexpr char *H_uitofp_i32_f32 = "__Sz_uitofp_i32_f32"; |
- const static constexpr char *H_uitofp_i32_f64 = "__Sz_uitofp_i32_f64"; |
- const static constexpr char *H_uitofp_i64_f32 = "__Sz_uitofp_i64_f32"; |
- const static constexpr char *H_uitofp_i64_f64 = "__Sz_uitofp_i64_f64"; |
- const static constexpr char *H_urem_i32 = "__umodsi3"; |
- const static constexpr char *H_urem_i64 = "__umoddi3"; |
+ |
+private: |
+ // Holds constant zero for each type. |
+ static Constant *ConstZeroForType[IceType_NUM]; |
John
2016/03/09 23:26:56
What do you think of making this array a non-stati
Karl
2016/03/16 22:50:52
Moved to global context, and used as cache inside
|
+ // Holds the constants representing each runtime helper function. |
+ static Constant *RuntimeHelperFunc[H_Num]; |
Karl
2016/03/16 22:50:52
Also moved this array to global context (as non-st
|
}; |
/// TargetDataLowering is used for "lowering" data including initializers for |