MLIR 23.0.0git
mlir::abi::test Namespace Reference

Functions

FunctionClassification classify (ArrayRef< Type > argTypes, Type returnType, const DataLayout &dl)
 Classify a function signature using the test target's predictable rules.
std::optional< FunctionClassificationparseClassificationAttr (DictionaryAttr attr, function_ref< InFlightDiagnostic()> emitError)
 Parse a FunctionClassification from a plain MLIR DictionaryAttr.

Function Documentation

◆ classify()

FunctionClassification mlir::abi::test::classify ( ArrayRef< Type > argTypes,
Type returnType,
const DataLayout & dl )

Classify a function signature using the test target's predictable rules.

The rules approximate x86_64 SysV thresholds for reviewer familiarity (see TestTarget.cpp for the full list) but are not a substitute for testing against a real ABIInfo. Real-ABI-shaped tests should use the classification-injection driver via parseClassificationAttr below.

Parameters
argTypesArgument types of the function.
returnTypeReturn type of the function.
dlDataLayout used for size and alignment queries.

Definition at line 111 of file TestTarget.cpp.

References mlir::abi::FunctionClassification::argInfos, and mlir::abi::FunctionClassification::returnInfo.

◆ parseClassificationAttr()

std::optional< FunctionClassification > mlir::abi::test::parseClassificationAttr ( DictionaryAttr attr,
function_ref< InFlightDiagnostic()> emitError )

Parse a FunctionClassification from a plain MLIR DictionaryAttr.

Schema (all keys are required unless marked optional):

{ return = { kind = "<kind>", ...per-kind keys... }, args = [ { kind = "<kind>", ...per-kind keys... }, ... ] }

Per-arg/return dictionary keys: kind: StringAttr. One of "direct", "extend", "indirect", "ignore", "expand".

For kind = "direct" (all optional): coerced_type: TypeAttr. ABI-coerced type, if different from the original. can_flatten: BoolAttr. Defaults to true.

For kind = "extend" (coerced_type required, sign_extend optional): coerced_type: TypeAttr. Required; the extended integer type. sign_extend: BoolAttr. Defaults to false (zero-extend).

For kind = "indirect" (indirect_align required, byval optional): indirect_align: IntegerAttr. Required; alignment of the pointed-to object in bytes. byval: BoolAttr. Defaults to true.

For kind = "ignore" / "expand": no extra keys.

Future schema additions tracked in projects/daily_log.md (Step 0c field-mapping table). When we add new fields to ArgClassification (e.g. direct_offset, extend_kind tristate, indirect_addr_space, indirect_realign), the corresponding optional keys go here.

Unknown keys cause a parse error (no silent ignore — keeps schema honest as it grows).

Parameters
attrThe dictionary attribute to parse.
emitErrorDiagnostic sink for parse errors.
Returns
The parsed classification, or std::nullopt on error.

Definition at line 216 of file TestTarget.cpp.

References mlir::abi::FunctionClassification::argInfos, mlir::emitError(), and mlir::abi::FunctionClassification::returnInfo.