Initial skeleton of Subzero.
This includes just enough code to build the high-level ICE IR and dump it back out again. There is a script szdiff.py that does a fuzzy diff of the input and output for verification. See the comment in szdiff.py for a description of the fuzziness.
Building llvm2ice requires LLVM headers, libs, and tools (e.g. FileCheck) to be present. These default to something like llvm_i686_linux_work/Release+Asserts/ based on the checked-out and built pnacl-llvm code; I'll try to figure out how to more automatically detect the build configuration.
"make check" runs the lit tests.
This CL has under 2000 lines of "interesting" Ice*.{h,cpp} code, plus 600 lines of llvm2ice.cpp driver code, and the rest is tests.
Here is the high-level mapping of source files to functionality:
IceDefs.h, IceTypes.h, IceTypes.cpp:
Commonly used types and utilities.
IceCfg.h, IceCfg.cpp:
Operations at the function level.
IceCfgNode.h, IceCfgNode.cpp:
Operations on basic blocks (nodes).
IceInst.h, IceInst.cpp:
Operations on instructions.
IceOperand.h, IceOperand.cpp:
Operations on operands, such as stack locations, physical registers, and constants.
BUG= none
R=jfb@chromium.org
Review URL: https://codereview.chromium.org/205613002
diff --git a/src/IceInst.def b/src/IceInst.def
new file mode 100644
index 0000000..60c613d
--- /dev/null
+++ b/src/IceInst.def
@@ -0,0 +1,89 @@
+//===- subzero/src/IceInst.def - X-macros for ICE instructions -*- C++ -*-===//
+//
+// The Subzero Code Generator
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines properties of ICE instructions in the form of
+// x-macros.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SUBZERO_SRC_ICEINST_DEF
+#define SUBZERO_SRC_ICEINST_DEF
+
+#define ICEINSTARITHMETIC_TABLE \
+ /* enum value, printable string, commutative */ \
+ X(Add, "add", 1) \
+ X(Fadd, "fadd", 0) \
+ X(Sub, "sub", 0) \
+ X(Fsub, "fsub", 0) \
+ X(Mul, "mul", 1) \
+ X(Fmul, "fmul", 0) \
+ X(Udiv, "udiv", 0) \
+ X(Sdiv, "sdiv", 0) \
+ X(Fdiv, "fdiv", 0) \
+ X(Urem, "urem", 0) \
+ X(Srem, "srem", 0) \
+ X(Frem, "frem", 0) \
+ X(Shl, "shl", 0) \
+ X(Lshr, "lshr", 0) \
+ X(Ashr, "ashr", 0) \
+ X(And, "and", 1) \
+ X(Or, "or", 1) \
+ X(Xor, "xor", 1)
+//#define X(tag, str, commutative)
+
+#define ICEINSTCAST_TABLE \
+ /* enum value, printable string */ \
+ X(Trunc, "trunc") \
+ X(Zext, "zext") \
+ X(Sext, "sext") \
+ X(Fptrunc, "fptrunc") \
+ X(Fpext, "fpext") \
+ X(Fptoui, "fptoui") \
+ X(Fptosi, "fptosi") \
+ X(Uitofp, "uitofp") \
+ X(Sitofp, "sitofp") \
+ X(Bitcast, "bitcast")
+//#define X(tag, str)
+
+#define ICEINSTFCMP_TABLE \
+ /* enum value, printable string */ \
+ X(False, "false") \
+ X(Oeq, "oeq") \
+ X(Ogt, "ogt") \
+ X(Oge, "oge") \
+ X(Olt, "olt") \
+ X(Ole, "ole") \
+ X(One, "one") \
+ X(Ord, "ord") \
+ X(Ueq, "ueq") \
+ X(Ugt, "ugt") \
+ X(Uge, "uge") \
+ X(Ult, "ult") \
+ X(Ule, "ule") \
+ X(Une, "une") \
+ X(Uno, "uno") \
+ X(True, "true")
+//#define X(tag, str)
+
+#define ICEINSTICMP_TABLE \
+ /* enum value, printable string */ \
+ X(Eq, "eq") \
+ X(Ne, "ne") \
+ X(Ugt, "ugt") \
+ X(Uge, "uge") \
+ X(Ult, "ult") \
+ X(Ule, "ule") \
+ X(Sgt, "sgt") \
+ X(Sge, "sge") \
+ X(Slt, "slt") \
+ X(Sle, "sle")
+//#define X(tag, str)
+
+
+#endif // SUBZERO_SRC_ICEINST_DEF