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