A question about LLVM_IntrOpBase

I don’t know how overloadedResults and overloadedOperands should be set.To be honest, despite the comments here, I still don’t understand the meaning of this code.Why do Operands and Results need to be overloaded? I don’t understand it.If anyone can help me, I would be grateful.Thanks!

class LLVM_IntrOpBase<Dialect dialect, string opName, string enumName,
                      list<int> overloadedResults, list<int> overloadedOperands,
                      list<Trait> traits, int numResults,
                      bit requiresAccessGroup = 0, bit requiresAliasScope = 0,
                      bit requiresFastmath = 0>
    : LLVM_OpBase<dialect, opName, !listconcat(
        !if(!gt(requiresFastmath, 0),
      Results<!if(!gt(numResults, 0), (outs LLVM_Type:$res), (outs))> {
  string resultPattern = !if(!gt(numResults, 1),
  string llvmEnumName = enumName;
  let llvmBuilder = [{
    llvm::Module *module = builder.GetInsertBlock()->getModule();
    llvm::Function *fn = llvm::Intrinsic::getDeclaration(
        llvm::Intrinsic::}] # enumName # [{,
        { }] # !interleave(!listconcat(
            ListIntSubst<resultPattern, overloadedResults>.lst,
                         overloadedOperands>.lst), ", ") # [{

From LLVM LangRef LLVM Language Reference Manual — LLVM 17.0.0git documentation

Some intrinsic functions can be overloaded, i.e., the intrinsic represents a family of functions that perform the same operation but on different data types.

You need to indicate which of the operands and results (by their position) are overloaded to MLIR knows about that and can pass additional arguments when creating the LLVM IR intrinsic call. If you already have the LLVM Tablegen definition of this intrinsics, mlir-tablegen can generate ODS for you following this example llvm-project/llvm-intrinsics.td at main · llvm/llvm-project · GitHub.

1 Like