aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CharHandler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/CharHandler.cc')
-rw-r--r--lib/CodeGen/CharHandler.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/CodeGen/CharHandler.cc b/lib/CodeGen/CharHandler.cc
new file mode 100644
index 0000000..5e9b502
--- /dev/null
+++ b/lib/CodeGen/CharHandler.cc
@@ -0,0 +1,15 @@
+#include "cps/CharHandler.h"
+
+using namespace llvm;
+using namespace cps;
+
+CharHandler::CharHandler(LLVMContext &Ctx, IRBuilder<> &B, llvm::Module &M)
+ : Context(Ctx), Builder(B), Module(M) {}
+
+Value *CharHandler::emitAsc(Value *CharVal) {
+ return Builder.CreateZExt(CharVal, Type::getInt32Ty(Context), "asc_val");
+}
+
+Value *CharHandler::emitChr(Value *IntVal) {
+ return Builder.CreateTrunc(IntVal, Type::getInt8Ty(Context), "chr_val");
+}