Skip to content

Commit

Permalink
feat: Added bitcast for pointers of integer or void types
Browse files Browse the repository at this point in the history
  • Loading branch information
alinalihassan committed May 27, 2022
1 parent dc0569f commit 95a45c4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/liblesma/Backend/Codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,9 @@ llvm::Value *Codegen::Cast(llvm::SMRange span, llvm::Value *val, llvm::Type *typ
return Builder->CreateSIToFP(val, type, ".tmp");
else if (val->getType()->isFloatingPointTy())
return Builder->CreateFPCast(val, type, ".tmp");
} else if (type->isPointerTy() && type->getPointerElementType()->isIntegerTy()) {
if (val->getType()->isPointerTy() && (val->getType()->getPointerElementType()->isIntegerTy() || val->getType()->getPointerElementType()->isVoidTy()))
return Builder->CreateBitCast(val, type, ".tmp");
}

throw CodegenError(span, "Unsupported Cast");
Expand Down

0 comments on commit 95a45c4

Please sign in to comment.