Skip to content

add CallFlags#48

Merged
can-lehmann merged 1 commit into
mainfrom
can-call-flags
Jun 21, 2026
Merged

add CallFlags#48
can-lehmann merged 1 commit into
mainfrom
can-call-flags

Conversation

@can-lehmann

Copy link
Copy Markdown
Owner

No description provided.

@github-actions

Copy link
Copy Markdown

Coverage

File Lines Functions Regions Branches
genext.hpp 🔴 54.38% 🟡 83.33% 🟡 76.14% 🟡 76.81%
jitir.hpp 🔴 51.22% 🔴 61.46% 🔴 55.80% 🔴 54.93%
jitir_llvmapi.hpp 🔴 56.13% 🔴 66.67% 🟢 92.98% 🔴 66.67%
llvmgen.hpp 🔴 64.40% 🟡 70.00% 🟡 83.71% 🟡 83.90%
lowerllvm.hpp 🔴 63.60% 🟡 75.00% 🔴 41.32% 🔴 56.49%
x86gen.hpp 🟡 74.12% 🟡 81.82% 🟡 75.78% 🟡 83.30%
x86insts.inc.hpp - - - -
TOTAL 🔴 56.21% 🔴 65.73% 🔴 64.25% 🔴 65.42%
Diff Coverage

Diff Coverage

Diff: origin/main...HEAD, staged and unstaged changes

  • genext.hpp (0.0%): Missing lines 798
  • jitir.hpp (57.1%): Missing lines 935-939,2818,2847-2849,2862,2873,4735,4739,4746-4747,4920-4921,8782
  • jitir_llvmapi.hpp (33.3%): Missing lines 891-892

Summary

  • Total: 46 lines
  • Missing: 21 lines
  • Coverage: 54%

genext.hpp

Lines 794-802

  794     build_args.push_back(args[0]);
  795     build_args.push_back(builder.build_const(Type::Int64, args.size() - 1));
  796     build_args.push_back(builder.build_const(Type::Int32, (uint64_t)i->type()));
  797     build_args.push_back(builder.build_const(Type::Int32, (uint64_t)i->call_conv()));
! 798     build_args.push_back(builder.build_const(Type::Int32, (uint64_t)i->flags()));
  799     Value* built = builder.build_call(syms.build_call, Type::Ptr, build_args);
  800     for (size_t it = 1; it < args.size(); it++) {
  801       builder.build_call(syms.set_arg, Type::Void, {
  802         built,

jitir.hpp

Lines 931-943

  931       return std::hash<uint32_t>()((uint32_t) flags); \
  932     } \
  933   }; \
  934   \
! 935   std::ostream& operator<<(std::ostream& stream, Flags flags) { \
! 936     metajit::PlainPrettyStream plain_stream(stream); \
! 937     flags.write(plain_stream); \
! 938     return stream; \
! 939   } \
  940   \
  941   metajit::PrettyStream& operator<<(metajit::PrettyStream& stream, const Flags& flags) { \
  942     flags.write(stream); \
  943     return stream; \

Lines 2814-2822

  2814   Type type() const { return _type; }
  2815   CallConv call_conv() const { return _call_conv; }
  2816   CallFlags flags() const { return _flags; }
  2817   void set_call_conv(CallConv call_conv) { _call_conv = call_conv; }
! 2818   void set_flags(CallFlags flags) { _flags = flags; }
  2819   void write(metajit::PrettyStream& stream) const override {
  2820     stream << Highlight::Keyword << "Call" << Highlight::None;;
  2821     stream << ' ';
  2822     bool is_first = true;

Lines 2843-2853

  2843     stream << "\"" << _type << "\"";
  2844     stream << ", ";
  2845     stream << "\"call_conv\": ";
  2846     stream << "\"" << _call_conv << "\"";
! 2847     stream << ", ";
! 2848     stream << "\"flags\": ";
! 2849     _flags.write_json(stream);
  2850     stream << "}";
  2851   }  bool equals(const Value* other) const override {
  2852     if (this == other) { return true; }
  2853     if (other == nullptr) { return false; }

Lines 2858-2866

  2858       if (arg(it) != other_inst->arg(it)) { return false; }
  2859     }
  2860     if (_type != other_inst->_type) { return false; }
  2861     if (_call_conv != other_inst->_call_conv) { return false; }
! 2862     if (_flags != other_inst->_flags) { return false; }
  2863     return true;
  2864   }
  2865   size_t hash() const override {
  2866     size_t hash = 7267317566803404502ULL;

Lines 2869-2877

  2869       hash ^= std::hash<Value*>()(arg(it));
  2870     }
  2871     hash ^= std::hash<Type>()(_type);
  2872     hash ^= std::hash<CallConv>()(_call_conv);
! 2873     hash ^= std::hash<CallFlags>()(_flags);
  2874     return hash;
  2875   }
  2876 };
  2877 class BranchInst final: public Inst {

Lines 4731-4743

  4731     Value* build_call(Value* callee,
  4732                       Type type,
  4733                       const lwir::Span<Value*>& args,
  4734                       CallConv call_conv = CallConv::Default,
! 4735                       CallFlags call_flags = CallFlags::None) {
  4736       // Calls may read/write memory reachable through pointers, so invalidate
  4737       // forwarding and exact aliasing state conservatively.
  4738       invalidate_memory_state();
! 4739       return Builder::build_call(callee, type, args, call_conv, call_flags);
  4740     }
  4741 
  4742     Value* build_call(Value* callee,
  4743                       Type type,

Lines 4742-4751

  4742     Value* build_call(Value* callee,
  4743                       Type type,
  4744                       const std::vector<Value*>& args,
  4745                       CallConv call_conv = CallConv::Default,
! 4746                       CallFlags call_flags = CallFlags::None) {
! 4747       return build_call(callee, type, lwir::Span<Value*>((Value**) args.data(), args.size()), call_conv, call_flags);
  4748     }
  4749 
  4750     template <class... Args>
  4751     Block* build_block(Args... args) {

Lines 4916-4925

  4916 }
  4917 void* jitir_build_lt_f_u(void* builder, void* a, void* b) {
  4918   return (void*)((::metajit::TraceBuilder*)builder)->build_lt_f_u((Value*) a, (Value*) b);
  4919 }
! 4920 void* jitir_build_call(void* builder, void* callee, uint64_t args, uint32_t type, uint32_t call_conv, uint32_t flags) {
! 4921   return (void*)((::metajit::TraceBuilder*)builder)->build_call((Value*) callee, (size_t) args, (Type) type, (CallConv) call_conv, (CallFlags) flags);
  4922 }
  4923 void* jitir_build_branch(void* builder, void* cond, void* true_block, void* false_block) {
  4924   return (void*)((::metajit::TraceBuilder*)builder)->build_branch((Value*) cond, (Block*) true_block, (Block*) false_block);
  4925 }

Lines 8778-8786

  8778   LtFUInst* clone = builder.build_lt_f_u(clone_arg(inst->arg(0), builder, values), clone_arg(inst->arg(1), builder, values));
  8779   return clone;
  8780 }
  8781 if (dynamic_cast<CallInst*>(inst)) {
! 8782   CallInst* clone = builder.build_call(clone_arg(inst->arg(0), builder, values), inst->arg_count() - 1, ((CallInst*) inst)->type(), ((CallInst*) inst)->call_conv(), ((CallInst*) inst)->flags());
  8783   for (size_t it = 1; it < inst->arg_count(); it++) {
  8784     clone->set_arg(it, clone_arg(inst->arg(it), builder, values));
  8785   }
  8786   return clone;

jitir_llvmapi.hpp

Lines 887-896

  887     build_args.push_back(args[0]);
  888     build_args.push_back(llvm::ConstantInt::get(llvm::Type::getInt64Ty(context), args.size() - 1, false));
  889     build_args.push_back(llvm::ConstantInt::get(llvm::Type::getInt32Ty(context), (uint64_t)i->type(), false));
  890     build_args.push_back(llvm::ConstantInt::get(llvm::Type::getInt32Ty(context), (uint64_t)i->call_conv(), false));
! 891     build_args.push_back(llvm::ConstantInt::get(llvm::Type::getInt32Ty(context), (uint64_t)i->flags(), false));
! 892     assert(build_args.size() == 6);
  893     llvm::Value* built = builder.CreateCall(api.build_call, build_args);
  894     for (size_t it = 1; it < args.size(); it++) {
  895       builder.CreateCall(api.set_arg, {
  896         built,

@can-lehmann
can-lehmann marked this pull request as ready for review June 21, 2026 04:13
@can-lehmann
can-lehmann merged commit b5fff7b into main Jun 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant