20 #include "llvm/IR/IRBuilder.h"
21 #include "llvm/IR/IntrinsicsRISCV.h"
22 #include "llvm/Support/raw_ostream.h"
32 auto intAttr = cast<IntegerAttr>(opcodeAttr);
33 unsigned xlenWidth = cast<IntegerType>(intAttr.getType()).getWidth();
34 return llvm::Type::getIntNTy(moduleTranslation.
getLLVMContext(), xlenWidth);
39 static llvm::Value *
createVL(llvm::IRBuilderBase &builder, llvm::Value *vl,
40 VectorType vtype, llvm::Type *xlen,
Location loc,
43 assert(vtype.isScalable() &&
44 "vl parameter must be set for scalable vectors");
45 return builder.CreateZExtOrTrunc(vl, xlen);
48 assert(vtype.getRank() == 1 &&
"Only 1-d fixed vectors are supported");
53 loc, moduleTranslation);
59 class VCIXDialectLLVMIRTranslationInterface
67 convertOperation(
Operation *op, llvm::IRBuilderBase &builder,
70 #include "mlir/Dialect/LLVMIR/VCIXConversions.inc"
78 registry.
insert<vcix::VCIXDialect>();
80 dialect->addInterfaces<VCIXDialectLLVMIRTranslationInterface>();
static llvm::Value * createVL(llvm::IRBuilderBase &builder, llvm::Value *vl, VectorType vtype, llvm::Type *xlen, Location loc, LLVM::ModuleTranslation &moduleTranslation)
Return VL for VCIX intrinsic.
static llvm::Type * getXlenType(Attribute opcodeAttr, LLVM::ModuleTranslation &moduleTranslation)
Infer XLen type from opcode's type.
Attributes are known-constant values of operations.
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
bool addExtension(TypeID extensionID, std::unique_ptr< DialectExtensionBase > extension)
Add the given extension to the registry.
Base class for dialect interfaces providing translation to LLVM IR.
LLVMTranslationDialectInterface(Dialect *dialect)
Implementation class for module translation.
llvm::LLVMContext & getLLVMContext() const
Returns the LLVM context in which the IR is being constructed.
MLIRContext & getContext()
Returns the MLIR context of the module being translated.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
MLIRContext is the top-level object for a collection of MLIR operations.
void appendDialectRegistry(const DialectRegistry ®istry)
Append the contents of the given dialect registry to the registry associated with this context.
Operation is the basic unit of execution within MLIR.
llvm::CallInst * createIntrinsicCall(llvm::IRBuilderBase &builder, llvm::Intrinsic::ID intrinsic, ArrayRef< llvm::Value * > args={}, ArrayRef< llvm::Type * > tys={})
Creates a call to an LLVM IR intrinsic function with the given arguments.
llvm::Constant * getLLVMConstant(llvm::Type *llvmType, Attribute attr, Location loc, const ModuleTranslation &moduleTranslation)
Create an LLVM IR constant of llvmType from the MLIR attribute attr.
Include the generated interface declarations.
void registerVCIXDialectTranslation(DialectRegistry ®istry)
Register the VCIX dialect and the translation from it to the LLVM IR in the given registry.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...