diff --git a/BitcodeEmitter.cpp b/BitcodeEmitter.cpp index b2671f2..7786088 100644 --- a/BitcodeEmitter.cpp +++ b/BitcodeEmitter.cpp @@ -51,24 +51,6 @@ struct BitcodeEmitter::Private { Scope scope; }; -static -llvm::Type *LLVMType(Type const& type) { - switch (type) { - case Type::INT: - return llvm::Type::getInt64Ty(getGlobalContext()); - case Type::CHAR: - return llvm::Type::getInt8Ty(getGlobalContext()); - case Type::FLOAT: - return llvm::Type::getFloatTy(getGlobalContext()); - case Type::BOOL: - return llvm::Type::getInt1Ty(getGlobalContext()); - case Type::DOUBLE: - return llvm::Type::getDoubleTy(getGlobalContext()); - case Type::VOID: - return llvm::Type::getVoidTy(getGlobalContext()); - } -} - static llvm::AllocaInst* allocateVar(llvm::Function *func, Id const& name, llvm::Type *type) { llvm::IRBuilder<> builder(&func->getEntryBlock(), func->getEntryBlock().begin()); @@ -99,6 +81,7 @@ bool reportError(std::initializer_list const& what) { #define I1 llvm::Type::getInt1Ty(getGlobalContext()) #define F llvm::Type::getFloatTy(getGlobalContext()) #define D llvm::Type::getDoubleTy(getGlobalContext()) +#define V llvm::Type::getVoidTy(getGlobalContext()) static const std::unordered_map> TYPECAST_MAP = { {I64, { {I8, I64}, {I1, I64}, { F, D}, {D, D}}}, @@ -108,6 +91,45 @@ static const std::unordered_mapgetType(); @@ -129,6 +151,7 @@ llvm::Type* deduceResultType(llvm::Value *left, llvm::Value *right) { #undef I1 #undef F #undef D +#undef V static inline bool isFP(llvm::Type *type) {