CIRCT
18.0.0git
|
#include "circt/Conversion/LLHDToLLVM.h"
#include "../PassDetail.h"
#include "circt/Conversion/CombToArith.h"
#include "circt/Conversion/CombToLLVM.h"
#include "circt/Conversion/HWToLLVM.h"
#include "circt/Dialect/LLHD/IR/LLHDDialect.h"
#include "circt/Dialect/LLHD/IR/LLHDOps.h"
#include "circt/Support/LLVM.h"
#include "circt/Support/Namespace.h"
#include "mlir/Conversion/ArithToLLVM/ArithToLLVM.h"
#include "mlir/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.h"
#include "mlir/Conversion/FuncToLLVM/ConvertFuncToLLVM.h"
#include "mlir/Conversion/FuncToLLVM/ConvertFuncToLLVMPass.h"
#include "mlir/Conversion/LLVMCommon/ConversionTarget.h"
#include "mlir/Conversion/LLVMCommon/Pattern.h"
#include "mlir/Conversion/ReconcileUnrealizedCasts/ReconcileUnrealizedCasts.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/DialectConversion.h"
Go to the source code of this file.
Typedefs | |
using | LoadOpConversion = OneToOneConvertToLLVMPattern< llhd::LoadOp, LLVM::LoadOp > |
Functions | |
static Value | getGlobalString (Location loc, OpBuilder &builder, const TypeConverter *typeConverter, LLVM::GlobalOp &str) |
Get an existing global string. More... | |
static LLVM::LLVMFuncOp | getOrInsertFunction (ModuleOp &module, ConversionPatternRewriter &rewriter, Location loc, std::string name, Type signature, bool insertBodyAndTerminator=false) |
Looks up a symbol and inserts a new functino at the beginning of the module's region in case the function does not exists. More... | |
static Type | getLLVMSigType (LLVM::LLVMDialect *dialect) |
Return the LLVM type used to represent a signal. More... | |
static std::vector< Value > | getSignalDetail (ConversionPatternRewriter &rewriter, LLVM::LLVMDialect *dialect, Location loc, Value signal, bool extractIndices=false) |
Extract the details from the given signal struct. More... | |
static Value | createSubSig (LLVM::LLVMDialect *dialect, ConversionPatternRewriter &rewriter, Location loc, std::vector< Value > originDetail, Value newPtr, Value newOffset) |
Create a subsignal struct. More... | |
static bool | isWaitDestArg (WaitOp op, Value val) |
Returns true if the given value is passed as an argument to the destination block of the given WaitOp. More... | |
static bool | isWaitDestArg (Operation *op) |
static Type | unwrapLLVMPtr (Type ty) |
Unwrap the given LLVM pointer type, returning its element value. More... | |
static Type | getProcPersistenceTy (LLVM::LLVMDialect *dialect, const TypeConverter *converter, ProcOp &proc) |
Gather the types of values that are used outside of the block they're defined in. More... | |
static void | insertComparisonBlock (ConversionPatternRewriter &rewriter, LLVM::LLVMDialect *dialect, Location loc, Region *body, Value resumeIdx, int currIdx, Block *trueDest, ValueRange trueDestArgs, Block *falseDest=nullptr) |
Insert a comparison block that either jumps to the trueDest block, if the resume index mathces the current index, or to falseDest otherwise. More... | |
static Value | gepPersistenceState (LLVM::LLVMDialect *dialect, Location loc, ConversionPatternRewriter &rewriter, Type elementTy, int index, Value state) |
Insert a GEP operation to the pointer of the i-th value in the process persistence table. More... | |
static void | persistValue (LLVM::LLVMDialect *dialect, Location loc, const TypeConverter *converter, ConversionPatternRewriter &rewriter, Type stateTy, int &i, Value state, Value persist) |
Persist a Value by storing it into the process persistence table, and substituting the uses that escape the block the operation is defined in with a load from the persistence table. More... | |
static void | insertPersistence (const TypeConverter *converter, ConversionPatternRewriter &rewriter, LLVM::LLVMDialect *dialect, Location loc, ProcOp &proc, Type &stateTy, LLVM::LLVMFuncOp &converted, Operation *splitEntryBefore) |
Insert the blocks and operations needed to persist values across suspension, as well as ones needed to resume execution at the right spot. More... | |
static LLVM::LLVMStructType | getRegStateTy (LLVM::LLVMDialect *dialect, Operation *entity) |
Return a struct type of arrays containing one entry for each RegOp condition that require more than one state of the trigger to infer it (i.e. More... | |
static Value | zextByOne (Location loc, ConversionPatternRewriter &rewriter, Value value) |
Create a zext operation by one bit on the given value. More... | |
static Value | adjustBitWidth (Location loc, ConversionPatternRewriter &rewriter, Type targetTy, Value value) |
Adjust the bithwidth of value to be the same as targetTy's bitwidth. More... | |
static unsigned | getIndexOfOperandResult (Operation *op, Value result) |
static Value | recursiveCloneInit (OpBuilder &initBuilder, IRMapping &mapping, Value init) |
Recursively clone the init origin of a sig operation into the init function, up to the initial constant value(s). More... | |
static bool | isArrayOrStruct (Type type) |
Check if the given type is either of LLHD's ArrayType, StructType, or LLVM array or struct type. More... | |
static std::pair< Value, Value > | shiftIntegerSigPointer (Location loc, LLVM::LLVMDialect *dialect, ConversionPatternRewriter &rewriter, Value pointer, Value index) |
Shift an integer signal pointer to obtain a view of the underlying value as if it was shifted. More... | |
static Value | shiftStructuredSigPointer (Location loc, ConversionPatternRewriter &rewriter, Type structTy, Type elemPtrTy, Value pointer, Value index) |
Shift the pointer of a structured-type (array or struct) signal, to change its view as if the desired slice/element was extracted. More... | |
static Value | shiftArraySigPointer (Location loc, ConversionPatternRewriter &rewriter, Type arrTy, Value pointer, Value index) |
Shift the pointer of an array-typed signal, to change its view as if the desired slice/element was extracted. More... | |
static Type | convertSigType (SigType type, LLVMTypeConverter &converter) |
static Type | convertTimeType (TimeType type, LLVMTypeConverter &converter) |
static Type | convertPtrType (PtrType type, LLVMTypeConverter &converter) |
using LoadOpConversion = OneToOneConvertToLLVMPattern<llhd::LoadOp, LLVM::LoadOp> |
Definition at line 1961 of file LLHDToLLVM.cpp.
|
static |
Adjust the bithwidth of value to be the same as targetTy's bitwidth.
Definition at line 477 of file LLHDToLLVM.cpp.
References value.
|
static |
Definition at line 621 of file LLHDToLLVM.cpp.
References circt::calyx::direction::get().
|
static |
Definition at line 608 of file LLHDToLLVM.cpp.
References circt::calyx::direction::get().
|
static |
Definition at line 616 of file LLHDToLLVM.cpp.
References circt::calyx::direction::get().
|
static |
Create a subsignal struct.
Definition at line 139 of file LLHDToLLVM.cpp.
References circt::calyx::direction::get(), and getLLVMSigType().
|
static |
Insert a GEP operation to the pointer of the i-th value in the process persistence table.
Definition at line 260 of file LLHDToLLVM.cpp.
References circt::calyx::direction::get().
Referenced by persistValue().
|
static |
Get an existing global string.
Definition at line 44 of file LLHDToLLVM.cpp.
References builder, and circt::calyx::direction::get().
|
static |
Definition at line 491 of file LLHDToLLVM.cpp.
Referenced by recursiveCloneInit().
|
static |
Return the LLVM type used to represent a signal.
It corresponds to a struct with the format: {valuePtr, bitOffset, instanceIndex, globalIndex}.
Definition at line 81 of file LLHDToLLVM.cpp.
References circt::calyx::direction::get().
Referenced by createSubSig(), and persistValue().
|
static |
Looks up a symbol and inserts a new functino at the beginning of the module's region in case the function does not exists.
If insertBodyAndTerminator is set, also adds the entry block and return terminator.
Definition at line 63 of file LLHDToLLVM.cpp.
|
static |
Gather the types of values that are used outside of the block they're defined in.
An LLVMType structure containing those types, in order of appearance, is returned.
Definition at line 196 of file LLHDToLLVM.cpp.
References isWaitDestArg().
|
static |
Return a struct type of arrays containing one entry for each RegOp condition that require more than one state of the trigger to infer it (i.e.
both
, rise
and fall
).
Definition at line 447 of file LLHDToLLVM.cpp.
References circt::calyx::direction::get().
|
static |
Extract the details from the given signal struct.
The details are returned in the original struct order.
Definition at line 90 of file LLHDToLLVM.cpp.
References circt::calyx::direction::get().
|
static |
Insert a comparison block that either jumps to the trueDest block, if the resume index mathces the current index, or to falseDest otherwise.
If no falseDest is provided, the next block is taken insead.
Definition at line 232 of file LLHDToLLVM.cpp.
References circt::calyx::direction::get().
Referenced by insertPersistence().
|
static |
Insert the blocks and operations needed to persist values across suspension, as well as ones needed to resume execution at the right spot.
Definition at line 354 of file LLHDToLLVM.cpp.
References circt::calyx::direction::get(), insertComparisonBlock(), isWaitDestArg(), and persistValue().
|
static |
Check if the given type is either of LLHD's ArrayType, StructType, or LLVM array or struct type.
Definition at line 546 of file LLHDToLLVM.cpp.
|
static |
Definition at line 179 of file LLHDToLLVM.cpp.
References isWaitDestArg().
|
static |
Returns true if the given value is passed as an argument to the destination block of the given WaitOp.
Definition at line 169 of file LLHDToLLVM.cpp.
Referenced by getProcPersistenceTy(), insertPersistence(), isWaitDestArg(), and persistValue().
|
static |
Persist a Value
by storing it into the process persistence table, and substituting the uses that escape the block the operation is defined in with a load from the persistence table.
Definition at line 278 of file LLHDToLLVM.cpp.
References gepPersistenceState(), getLLVMSigType(), and isWaitDestArg().
Referenced by insertPersistence().
|
static |
Recursively clone the init origin of a sig operation into the init function, up to the initial constant value(s).
This is required to clone the initialization of array and struct signals, where the init operand cannot originate from a constant operation.
Definition at line 504 of file LLHDToLLVM.cpp.
References getIndexOfOperandResult().
|
static |
Shift the pointer of an array-typed signal, to change its view as if the desired slice/element was extracted.
Definition at line 594 of file LLHDToLLVM.cpp.
References circt::calyx::direction::get(), shiftStructuredSigPointer(), and zextByOne().
|
static |
Shift an integer signal pointer to obtain a view of the underlying value as if it was shifted.
Definition at line 554 of file LLHDToLLVM.cpp.
References circt::calyx::direction::get().
|
static |
Shift the pointer of a structured-type (array or struct) signal, to change its view as if the desired slice/element was extracted.
Definition at line 575 of file LLHDToLLVM.cpp.
References circt::calyx::direction::get().
Referenced by shiftArraySigPointer().
|
static |
Unwrap the given LLVM pointer type, returning its element value.
Definition at line 188 of file LLHDToLLVM.cpp.
|
static |
Create a zext operation by one bit on the given value.
This is useful when passing unsigned indexes to a GEP instruction, which treats indexes as signed values, to avoid unexpected "sign overflows".
Definition at line 468 of file LLHDToLLVM.cpp.
References circt::calyx::direction::get(), and value.
Referenced by shiftArraySigPointer().