aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/IntegerHandler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/IntegerHandler.cc')
-rw-r--r--lib/CodeGen/IntegerHandler.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/CodeGen/IntegerHandler.cc b/lib/CodeGen/IntegerHandler.cc
new file mode 100644
index 0000000..8161593
--- /dev/null
+++ b/lib/CodeGen/IntegerHandler.cc
@@ -0,0 +1,16 @@
+#include "cps/IntegerHandler.h"
+
+using namespace llvm;
+using namespace cps;
+
+void IntegerHandler::emitDeclare(const std::string &Name) {
+ Function *TheFunction = Builder.GetInsertBlock()->getParent();
+ IRBuilder<> TmpB(&TheFunction->getEntryBlock(), TheFunction->getEntryBlock().begin());
+ AllocaInst *Alloca = TmpB.CreateAlloca(Type::getInt64Ty(Context), nullptr, Name);
+ Builder.CreateStore(ConstantInt::get(Context, APInt(64, 0)), Alloca);
+ NamedValues[Name] = Alloca;
+}
+
+Value *IntegerHandler::createLiteral(int64_t Val) {
+ return ConstantInt::get(Context, APInt(64, Val, true));
+}