diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/ByteCode/Compiler.cpp | 12 | ||||
-rw-r--r-- | clang/lib/CIR/CodeGen/CIRGenRecordLayout.h | 2 | ||||
-rw-r--r-- | clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 2 |
3 files changed, 12 insertions, 4 deletions
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 0b7b6cd..c71fd22 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -540,7 +540,8 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) { if (const auto *IL = dyn_cast<IntegerLiteral>(SubExpr)) { if (ToT != PT_IntAP && ToT != PT_IntAPS && FromT != PT_IntAP && FromT != PT_IntAPS && !CE->getType()->isEnumeralType()) - return this->emitConst(IL->getValue(), CE); + return this->emitConst(APSInt(IL->getValue(), !isSignedType(*FromT)), + CE); if (!this->emitConst(IL->getValue(), SubExpr)) return false; } else { @@ -4541,7 +4542,14 @@ bool Compiler<Emitter>::emitConst(T Value, const Expr *E) { template <class Emitter> bool Compiler<Emitter>::emitConst(const APSInt &Value, PrimType Ty, const Expr *E) { - return this->emitConst(static_cast<const APInt &>(Value), Ty, E); + if (Ty == PT_IntAPS) + return this->emitConstIntAPS(Value, E); + if (Ty == PT_IntAP) + return this->emitConstIntAP(Value, E); + + if (Value.isSigned()) + return this->emitConst(Value.getSExtValue(), Ty, E); + return this->emitConst(Value.getZExtValue(), Ty, E); } template <class Emitter> diff --git a/clang/lib/CIR/CodeGen/CIRGenRecordLayout.h b/clang/lib/CIR/CodeGen/CIRGenRecordLayout.h index 914ef16..bf0ddc5 100644 --- a/clang/lib/CIR/CodeGen/CIRGenRecordLayout.h +++ b/clang/lib/CIR/CodeGen/CIRGenRecordLayout.h @@ -57,7 +57,7 @@ namespace clang::CIRGen { /// cir.func @store_field() { /// %0 = cir.alloca !rec_S, !cir.ptr<!rec_S>, ["s"] {alignment = 4 : i64} /// %1 = cir.const #cir.int<2> : !s32i -/// %2 = cir.cast(integral, %1 : !s32i), !u32i +/// %2 = cir.cast integral %1 : !s32i -> !u32i /// %3 = cir.get_member %0[3] {name = "more_bits"} : !cir.ptr<!rec_S> -> /// !cir.ptr<!u16i> /// %4 = cir.set_bitfield(#bfi_more_bits, %3 : diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp index 0f309e4..22f069d 100644 --- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp +++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp @@ -2425,7 +2425,7 @@ static void prepareTypeConverter(mlir::LLVMTypeConverter &converter, // For instance, this CIR code: // // cir.func @foo(%arg0: !s32i) -> !s32i { -// %4 = cir.cast(int_to_bool, %arg0 : !s32i), !cir.bool +// %4 = cir.cast int_to_bool %arg0 : !s32i -> !cir.bool // cir.if %4 { // %5 = cir.const #cir.int<1> : !s32i // cir.return %5 : !s32i |