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/Makefile b/Makefile
new file mode 100644
index 0000000..e32ae89
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,74 @@
+# The following variables will likely need to be modified, depending on where
+# and how you built LLVM & Clang. They can be overridden in a command-line
+# invocation of make, like:
+#
+#   make LLVM_SRC_PATH=<path> LLVM_BIN_PATH=<path> ...
+#
+
+# LLVM_SRC_PATH is the path to the root of the checked out source code. This
+# directory should contain the configure script, the include/ and lib/
+# directories of LLVM, Clang in tools/clang/, etc.
+# Alternatively, if you're building vs. a binary download of LLVM, then
+# LLVM_SRC_PATH can point to the main untarred directory.
+LLVM_SRC_PATH ?= ../llvm
+
+# LLVM_BIN_PATH is the directory where binaries are placed by the LLVM build
+# process. It should contain the tools like opt, llc and clang. The default
+# reflects a debug build with autotools (configure & make).
+LLVM_BIN_PATH ?= $(shell readlink -e \
+	../../out/llvm_i686_linux_work/Release+Asserts/bin)
+
+$(info -----------------------------------------------)
+$(info Using LLVM_SRC_PATH = $(LLVM_SRC_PATH))
+$(info Using LLVM_BIN_PATH = $(LLVM_BIN_PATH))
+$(info -----------------------------------------------)
+
+LLVM_CXXFLAGS := `$(LLVM_BIN_PATH)/llvm-config --cxxflags`
+LLVM_LDFLAGS := `$(LLVM_BIN_PATH)/llvm-config --ldflags --libs`
+
+# It's recommended that CXX matches the compiler you used to build LLVM itself.
+OPTLEVEL := -O0
+CXX := g++
+CXXFLAGS := -Wall -Werror -fno-rtti -fno-exceptions \
+	$(OPTLEVEL) -g $(LLVM_CXXFLAGS) -m32
+LDFLAGS := -m32
+
+SRCS= \
+	IceCfg.cpp \
+	IceCfgNode.cpp \
+	IceGlobalContext.cpp \
+	IceInst.cpp \
+	IceOperand.cpp \
+	IceTypes.cpp \
+	llvm2ice.cpp
+
+OBJS=$(patsubst %.cpp, build/%.o, $(SRCS))
+
+# Keep all the first target so it's the default.
+all: llvm2ice
+
+.PHONY: all
+
+llvm2ice: $(OBJS)
+	$(CXX) $(LDFLAGS) -o $@ $^ $(LLVM_LDFLAGS) -ldl
+
+# TODO: Be more precise than "*.h" here and elsewhere.
+$(OBJS): build/%.o: src/%.cpp src/*.h src/*.def
+	$(CXX) -c $(CXXFLAGS) $< -o $@
+
+$(OBJS): | build
+
+build:
+	@mkdir -p $@
+
+check: llvm2ice
+	LLVM_BIN_PATH=$(LLVM_BIN_PATH) \
+	$(LLVM_SRC_PATH)/utils/lit/lit.py -sv tests_lit
+
+# TODO: Fix the use of wildcards.
+format:
+	$(LLVM_BIN_PATH)/clang-format -style=LLVM -i \
+	src/Ice*.h src/Ice*.cpp src/llvm2ice.cpp
+
+clean:
+	rm -rf llvm2ice *.o build/