From 8b854273e2dfdb676ad05fdc3ba05d166d1c0db8 Mon Sep 17 00:00:00 2001 From: Raphael Amorim Date: Fri, 22 May 2026 09:35:32 +0200 Subject: [PATCH] small cleanups --- src/astgen.cpp | 2 -- src/jir_codegen.cpp | 18 +++++++++--------- tests/cpp/test_codegen_errors.cpp | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/astgen.cpp b/src/astgen.cpp index a8cf40b..07e8612 100644 --- a/src/astgen.cpp +++ b/src/astgen.cpp @@ -2285,9 +2285,7 @@ static void astgenContinue(AstGenCtx &gctx) { emitBr(gctx, gctx.loopStack.back().continueBlock); } -// ===================================================================== // Match lowering (Phase 5) -// ===================================================================== // // Each match desugars to: // - eval scrutinee diff --git a/src/jir_codegen.cpp b/src/jir_codegen.cpp index f8b32b7..17ddbdc 100644 --- a/src/jir_codegen.cpp +++ b/src/jir_codegen.cpp @@ -166,7 +166,7 @@ static JamValueRef emitInstImpl(JirCodegenCtx &lctx, JirRef r) { JamLLVMBuildStore(lctx.ctx.getBuilder(), val, ptr); return nullptr; } - // === Integer arithmetic === + // Integer arithmetic case JirTag::Add: { JamValueRef a = emitInst(lctx, inst.a); JamValueRef b = emitInst(lctx, inst.b); @@ -202,7 +202,7 @@ static JamValueRef emitInstImpl(JirCodegenCtx &lctx, JirRef r) { JamValueRef b = emitInst(lctx, inst.b); return JamLLVMBuildURem(lctx.ctx.getBuilder(), a, b, "urem"); } - // === Float arithmetic === + // Float arithmetic case JirTag::FAdd: { JamValueRef a = emitInst(lctx, inst.a); JamValueRef b = emitInst(lctx, inst.b); @@ -232,7 +232,7 @@ static JamValueRef emitInstImpl(JirCodegenCtx &lctx, JirRef r) { JamValueRef a = emitInst(lctx, inst.a); return JamLLVMBuildFNeg(lctx.ctx.getBuilder(), a, "fneg"); } - // === Integer comparison === + // Integer comparison case JirTag::ICmpEq: return buildICmp(lctx, JAM_ICMP_EQ, emitInst(lctx, inst.a), emitInst(lctx, inst.b), "eq"); @@ -263,7 +263,7 @@ static JamValueRef emitInstImpl(JirCodegenCtx &lctx, JirRef r) { case JirTag::ICmpUge: return buildICmp(lctx, JAM_ICMP_UGE, emitInst(lctx, inst.a), emitInst(lctx, inst.b), "uge"); - // === Float comparison === + // Float comparison case JirTag::FCmpOeq: return buildFCmp(lctx, JAM_FCMP_OEQ, emitInst(lctx, inst.a), emitInst(lctx, inst.b), "oeq"); @@ -282,7 +282,7 @@ static JamValueRef emitInstImpl(JirCodegenCtx &lctx, JirRef r) { case JirTag::FCmpOge: return buildFCmp(lctx, JAM_FCMP_OGE, emitInst(lctx, inst.a), emitInst(lctx, inst.b), "oge"); - // === Bitwise / shift === + // Bitwise / shift case JirTag::BitAnd: return JamLLVMBuildAnd(lctx.ctx.getBuilder(), emitInst(lctx, inst.a), emitInst(lctx, inst.b), "and"); @@ -314,7 +314,7 @@ static JamValueRef emitInstImpl(JirCodegenCtx &lctx, JirRef r) { JamValueRef one = JamLLVMConstInt(lctx.ctx.getInt1Type(), 1, false); return JamLLVMBuildXor(lctx.ctx.getBuilder(), v, one, "lnot"); } - // === Type conversions === + // Type conversions case JirTag::ZExt: { JamValueRef v = emitInst(lctx, inst.a); JamTypeRef ty = lctx.ctx.getLLVMType(inst.ty); @@ -402,7 +402,7 @@ static JamValueRef emitInstImpl(JirCodegenCtx &lctx, JirRef r) { return JamLLVMBuildPtrToInt(lctx.ctx.getBuilder(), fnVal, ty, "fnref.u64"); } - // === Aggregates === + // Aggregates case JirTag::StructLit: { JamTypeRef ty = lctx.ctx.getLLVMType(inst.ty); JirExtraIdx extra = static_cast(inst.b); @@ -593,7 +593,7 @@ static JamValueRef emitInstImpl(JirCodegenCtx &lctx, JirRef r) { return JamLLVMBuildLoad(lctx.ctx.getBuilder(), fieldTy, fieldPtr, "enum.payload.val"); } - // === Function call === + // Function call case JirTag::Call: { // `inst.a` is the StringIdx of the LLVM symbol name — // astgen has already done the mangling (test functions get @@ -688,7 +688,7 @@ static JamValueRef emitInstImpl(JirCodegenCtx &lctx, JirRef r) { lctx.ctx.getBuilder(), llvmFnTy, calleeVal, args.data(), static_cast(args.size()), resultName); } - // === Control === + // Control case JirTag::Br: { JirBlockRef target = static_cast(inst.a); JamLLVMBuildBr(lctx.ctx.getBuilder(), lctx.blockMap.at(target)); diff --git a/tests/cpp/test_codegen_errors.cpp b/tests/cpp/test_codegen_errors.cpp index 63d352e..0f02d5e 100644 --- a/tests/cpp/test_codegen_errors.cpp +++ b/tests/cpp/test_codegen_errors.cpp @@ -456,7 +456,7 @@ fn main() {} ASSERT_TRUE(stderrContains(r, "Private")); } - // === Fn-as-value (Rust-style item coercion) + ptr↔int casts ==== + // Fn-as-value (Rust-style item coercion) + ptr↔int casts // // These exercise the `export fn` callback workflow needed for // SDL_AudioSpec-style C-ABI callbacks. The bare-name form mirrors -- 2.51.2