Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions include/circt-c/Dialect/LLHD.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,9 @@ MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(LLHD, llhd);

/// Check if a type is a time type.
MLIR_CAPI_EXPORTED bool llhdTypeIsATimeType(MlirType);
/// Check if a type is a signal type.
MLIR_CAPI_EXPORTED bool llhdTypeIsASignalType(MlirType);
/// Check if a type is a pointer type.
MLIR_CAPI_EXPORTED bool llhdTypeIsAPointerType(MlirType);

/// Create a time type.
MLIR_CAPI_EXPORTED MlirType llhdTimeTypeGet(MlirContext ctx);
/// Create a signal type.
MLIR_CAPI_EXPORTED MlirType llhdSignalTypeGet(MlirType element);
/// Create a pointer type.
MLIR_CAPI_EXPORTED MlirType llhdPointerTypeGet(MlirType element);

/// Get the inner type of a signal.
MLIR_CAPI_EXPORTED MlirType llhdSignalTypeGetElementType(MlirType);
/// Get the inner type of a pointer.
MLIR_CAPI_EXPORTED MlirType llhdPointerTypeGetElementType(MlirType);

//===----------------------------------------------------------------------===//
// Attributes
Expand Down
145 changes: 0 additions & 145 deletions include/circt/Dialect/LLHD/IR/LLHDExtractOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ class SigArrayElementTypeConstraint<string result, string input>
input, result,
"hw::InOutType::get(llhd::getLLHDElementType($_self))">;

class PtrArrayElementTypeConstraint<string result, string input>
: TypesMatchWith<"result must be a pointer of the array element type",
input, result,
"llhd::PtrType::get(llhd::getLLHDElementType($_self))">;

class SameSigPtrArrayElementTypeConstraint<string result, string input>
: PredOpTrait<"arrays element type must match",
CPred<"llhd::getLLHDElementType($" # result # ".getType()) == "
Expand Down Expand Up @@ -76,33 +71,6 @@ def SigExtractOp : LLHDOp<"sig.extract",
let hasFolder = true;
}

def PtrExtractOp : LLHDOp<"ptr.extract",
[Pure,
SmallerOrEqualResultTypeWidthConstraint<"result", "input">,
SigPtrIndexBitWidthConstraint<"lowBit", "input">]> {

let summary = "Extract a range of bits from an integer pointer";
let description = [{
The `llhd.ptr.extract` operation allows to access a range of bits
of the `$input` operand, starting at the index given by the `$lowBit`
operand. The result length is defined by the result type.
}];

let arguments = (ins LLHDPtrTypeOf<[HWIntegerType]>:$input,
HWIntegerType:$lowBit);
let results = (outs LLHDPtrTypeOf<[HWIntegerType]>: $result);

let assemblyFormat = [{
$input `from` $lowBit attr-dict `:` functional-type($input, $result)
}];

let extraClassDeclaration = [{
unsigned getResultWidth() { return getLLHDTypeWidth(getResult().getType()); }
unsigned getInputWidth() { return getLLHDTypeWidth(getInput().getType()); }
}];
let hasFolder = true;
}

//===----------------------------------------------------------------------===//
// Array Operations
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -158,57 +126,6 @@ def SigArraySliceOp : LLHDOp<"sig.array_slice",
let hasCanonicalizeMethod = true;
}

def PtrArraySliceOp : LLHDOp<"ptr.array_slice",
[Pure,
SmallerOrEqualResultTypeWidthConstraint<"result", "input">,
SameSigPtrArrayElementTypeConstraint<"result", "input">,
SigPtrIndexBitWidthConstraint<"lowIndex", "input">]> {

let summary = "Get a range of consecutive values from a pointer to an array";
let description = [{
The `llhd.ptr.array_slice` operation allows to access a sub-range of the
`$input` operand, starting at the index given by the `$lowIndex`
operand. The resulting slice length is defined by the result type.
Returns a pointer aliasing the elements of the slice.

Width of 'lowIndex' is defined to be the precise number of bits required to
index the 'input' array. More precisely: for an input array of size M,
the width of 'lowIndex' is ceil(log2(M)). Lower and upper bound indexes
which are larger than the size of the 'input' array results in undefined
behavior.

Example:

```mlir
%3 = llhd.ptr.array_slice %input at %lowIndex :
(!llhd.ptr<!hw.array<4xi8>>) -> !llhd.ptr<!hw.array<2xi8>>
```
}];

let arguments = (ins LLHDPtrTypeOf<[ArrayType]>: $input,
HWIntegerType: $lowIndex);
let results = (outs LLHDPtrTypeOf<[ArrayType]>: $result);

let assemblyFormat = [{
$input `at` $lowIndex attr-dict `:` functional-type($input, $result)
}];

let extraClassDeclaration = [{
unsigned getResultWidth() { return getLLHDTypeWidth(getResult().getType()); }
unsigned getInputWidth() { return getLLHDTypeWidth(getInput().getType()); }
hw::ArrayType getInputArrayType() {
return llvm::cast<hw::ArrayType>(llvm::cast<llhd::PtrType>(
getInput().getType()).getElementType());
}
hw::ArrayType getResultArrayType() {
return llvm::cast<hw::ArrayType>(llvm::cast<llhd::PtrType>(
getResult().getType()).getElementType());
}
}];
let hasFolder = true;
let hasCanonicalizeMethod = true;
}

def SigArrayGetOp : LLHDOp<"sig.array_get",
[Pure,
DeclareOpInterfaceMethods<DestructurableAccessorOpInterface>,
Expand Down Expand Up @@ -243,38 +160,6 @@ def SigArrayGetOp : LLHDOp<"sig.array_get",
}];
}

def PtrArrayGetOp : LLHDOp<"ptr.array_get",
[Pure,
SigPtrIndexBitWidthConstraint<"index", "input">,
PtrArrayElementTypeConstraint<"result", "input">]> {

let summary = "Extract an element from a pointer to an array.";
let description = [{
The `llhd.ptr.array_get` operation allows to access the element of the
`$input` operand at position `$index`. A new pointer aliasing the element
will be returned.

Example:

```mlir
// Returns a !llhd.ptr<i8>
%0 = llhd.ptr.array_get %arr[%index] : !llhd.ptr<!hw.array<4xi8>>
```
}];

let arguments = (ins LLHDPtrTypeOf<[ArrayType]>:$input, HWIntegerType:$index);
let results = (outs LLHDPtrTypeOf<[HWNonInOutType]>: $result);

let assemblyFormat = "$input `[` $index `]` attr-dict `:` qualified(type($input))";

let extraClassDeclaration = [{
hw::ArrayType getArrayType() {
return llvm::cast<hw::ArrayType>(llvm::cast<llhd::PtrType>(
getInput().getType()).getElementType());
}
}];
}

//===----------------------------------------------------------------------===//
// Structure Operations
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -310,33 +195,3 @@ def SigStructExtractOp : LLHDOp<"sig.struct_extract", [Pure,
}
}];
}

def PtrStructExtractOp : LLHDOp<"ptr.struct_extract", [Pure,
DeclareOpInterfaceMethods<InferTypeOpInterface>, InferTypeOpInterface]> {
let summary = "Extract a field from a pointer to a struct.";
let description = [{
The `llhd.ptr.struct_extract` operation allows access to the field of the
`$input` operand given by its name via the `$field` attribute.
A new pointer aliasing the field will be returned.

Example:

```mlir
// Returns a !llhd.ptr<i8>
%0 = llhd.ptr.struct_extract %struct["foo"]
: !llhd.ptr<!hw.struct<foo: i8, bar: i16>>
```
}];

let arguments = (ins LLHDPtrTypeOf<[StructType]>:$input, StrAttr:$field);
let results = (outs LLHDPtrTypeOf<[HWNonInOutType]>:$result);

let assemblyFormat = "$input `[` $field `]` attr-dict `:` qualified(type($input))";

let extraClassDeclaration = [{
hw::StructType getStructType() {
return llvm::cast<hw::StructType>(llvm::cast<llhd::PtrType>(
getInput().getType()).getElementType());
}
}];
}
93 changes: 0 additions & 93 deletions include/circt/Dialect/LLHD/IR/LLHDMemoryOps.td

This file was deleted.

1 change: 0 additions & 1 deletion include/circt/Dialect/LLHD/IR/LLHDOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ include "circt/Dialect/LLHD/IR/LLHDValueOps.td"
include "circt/Dialect/LLHD/IR/LLHDSignalOps.td"
include "circt/Dialect/LLHD/IR/LLHDExtractOps.td"
include "circt/Dialect/LLHD/IR/LLHDStructureOps.td"
include "circt/Dialect/LLHD/IR/LLHDMemoryOps.td"

#endif // CIRCT_DIALECT_LLHD_IR_LLHDOPS_TD
29 changes: 0 additions & 29 deletions include/circt/Dialect/LLHD/IR/LLHDTypes.td
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,6 @@ class LLHDType<string name> : TypeDef<LLHDDialect, name> { }
// Type declarations
//===----------------------------------------------------------------------===//

def LLHDPtrType : LLHDType<"Ptr"> {
let summary = "pointer type";
let description = [{
Represents a pointer to a memory location holding a value of its element
type. May be used to load and store data in distinct memory slots.
}];

let mnemonic = "ptr";
let parameters = (ins "::mlir::Type":$elementType);
let assemblyFormat = "`<` $elementType `>`";

let builders = [
AttrBuilderWithInferredContext<(ins "::mlir::Type":$elementType), [{
return $_get(elementType.getContext(), elementType);
}]>
];
}

def LLHDTimeType : LLHDType<"Time"> {
let summary = "time type";
let description = [{
Expand All @@ -50,20 +32,9 @@ def LLHDTimeType : LLHDType<"Time"> {
infinitesimal time steps, and an epsilon value representing an absolute time
slot within a delta step (used to model SystemVerilog scheduling regions).
}];

let mnemonic = "time";
}

//===----------------------------------------------------------------------===//
// Type Constraints
//===----------------------------------------------------------------------===//

class LLHDPtrTypeOf<list<Type> allowedTypes>
: ContainerType<AnyTypeOf<allowedTypes>, CPred<"llvm::isa<PtrType>($_self)">,
"llvm::cast<PtrType>($_self).getElementType()", "LLHD pointer type">;

def LLHDAnySigOrPtrType : AnyTypeOf<[LLHDPtrType, InOutType]>;

//===----------------------------------------------------------------------===//
// Attribute declarations
//===----------------------------------------------------------------------===//
Expand Down
Loading