Skip to content

[CIR] Merge the mlir::cir namespace into cir #1084

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 8, 2024
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
8 changes: 3 additions & 5 deletions clang/include/clang/CIR/ABIArgInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ class ABIArgInfo {
}
static ABIArgInfo getZeroExtend(mlir::Type Ty, mlir::Type T = nullptr) {
// NOTE(cir): Enumerations are IntTypes in CIR.
assert(mlir::isa<mlir::cir::IntType>(Ty) ||
mlir::isa<mlir::cir::BoolType>(Ty));
assert(mlir::isa<cir::IntType>(Ty) || mlir::isa<cir::BoolType>(Ty));
auto AI = ABIArgInfo(Extend);
AI.setCoerceToType(T);
AI.setPaddingType(nullptr);
Expand All @@ -190,9 +189,8 @@ class ABIArgInfo {
// NOTE(cir): The original can apply this method on both integers and
// enumerations, but in CIR, these two types are one and the same. Booleans
// will also fall into this category, but they have their own type.
if (mlir::isa<mlir::cir::IntType>(Ty) &&
mlir::cast<mlir::cir::IntType>(Ty).isSigned())
return getSignExtend(mlir::cast<mlir::cir::IntType>(Ty), T);
if (mlir::isa<cir::IntType>(Ty) && mlir::cast<cir::IntType>(Ty).isSigned())
return getSignExtend(mlir::cast<cir::IntType>(Ty), T);
return getZeroExtend(Ty, T);
}

Expand Down
472 changes: 221 additions & 251 deletions clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions clang/include/clang/CIR/Dialect/IR/CIRAttrs.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ class VarDecl;
class RecordDecl;
} // namespace clang

namespace mlir {
namespace cir {
class ArrayType;
class StructType;
class BoolType;
} // namespace cir
} // namespace mlir

#define GET_ATTRDEF_CLASSES
#include "clang/CIR/Dialect/IR/CIROpsAttributes.h.inc"
Expand Down
134 changes: 67 additions & 67 deletions clang/include/clang/CIR/Dialect/IR/CIRAttrs.td

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions clang/include/clang/CIR/Dialect/IR/CIRDataLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class CIRDataLayout {
/// struct, its size, and the offsets of its fields.
///
/// Note that this information is lazily cached.
const StructLayout *getStructLayout(mlir::cir::StructType Ty) const;
const StructLayout *getStructLayout(cir::StructType Ty) const;

/// Internal helper method that returns requested alignment for type.
llvm::Align getAlignment(mlir::Type Ty, bool abiOrPref) const;
Expand Down Expand Up @@ -93,17 +93,17 @@ class CIRDataLayout {
}

llvm::TypeSize getPointerTypeSizeInBits(mlir::Type Ty) const {
assert(mlir::isa<mlir::cir::PointerType>(Ty) &&
assert(mlir::isa<cir::PointerType>(Ty) &&
"This should only be called with a pointer type");
return layout.getTypeSizeInBits(Ty);
}

llvm::TypeSize getTypeSizeInBits(mlir::Type Ty) const;

mlir::Type getIntPtrType(mlir::Type Ty) const {
assert(mlir::isa<mlir::cir::PointerType>(Ty) && "Expected pointer type");
auto IntTy = mlir::cir::IntType::get(Ty.getContext(),
getPointerTypeSizeInBits(Ty), false);
assert(mlir::isa<cir::PointerType>(Ty) && "Expected pointer type");
auto IntTy =
cir::IntType::get(Ty.getContext(), getPointerTypeSizeInBits(Ty), false);
return IntTy;
}
};
Expand Down Expand Up @@ -153,7 +153,7 @@ class StructLayout final
private:
friend class CIRDataLayout; // Only DataLayout can create this class

StructLayout(mlir::cir::StructType ST, const CIRDataLayout &DL);
StructLayout(cir::StructType ST, const CIRDataLayout &DL);

size_t numTrailingObjects(OverloadToken<llvm::TypeSize>) const {
return NumElements;
Expand Down
12 changes: 6 additions & 6 deletions clang/include/clang/CIR/Dialect/IR/CIRDialect.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ template <typename ConcreteType>
class SameFirstOperandAndResultType
: public TraitBase<ConcreteType, SameFirstOperandAndResultType> {
public:
static LogicalResult verifyTrait(Operation *op) {
static llvm::LogicalResult verifyTrait(Operation *op) {
return impl::verifySameFirstOperandAndResultType(op);
}
};
Expand All @@ -67,7 +67,7 @@ template <typename ConcreteType>
class SameSecondOperandAndResultType
: public TraitBase<ConcreteType, SameSecondOperandAndResultType> {
public:
static LogicalResult verifyTrait(Operation *op) {
static llvm::LogicalResult verifyTrait(Operation *op) {
return impl::verifySameSecondOperandAndResultType(op);
}
};
Expand All @@ -79,19 +79,19 @@ template <typename ConcreteType>
class SameFirstSecondOperandAndResultType
: public TraitBase<ConcreteType, SameFirstSecondOperandAndResultType> {
public:
static LogicalResult verifyTrait(Operation *op) {
static llvm::LogicalResult verifyTrait(Operation *op) {
return impl::verifySameFirstSecondOperandAndResultType(op);
}
};

} // namespace OpTrait

} // namespace mlir

namespace cir {
void buildTerminatedBody(OpBuilder &builder, Location loc);
void buildTerminatedBody(mlir::OpBuilder &builder, mlir::Location loc);
} // namespace cir

} // namespace mlir

#define GET_OP_CLASSES
#include "clang/CIR/Dialect/IR/CIROps.h.inc"

Expand Down
16 changes: 8 additions & 8 deletions clang/include/clang/CIR/Dialect/IR/CIRDialect.td
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def CIR_Dialect : Dialect {
let summary = "A high-level dialect for analyzing and optimizing Clang "
"supported languages";

let cppNamespace = "::mlir::cir";
let cppNamespace = "::cir";

let useDefaultAttributePrinterParser = 0;
let useDefaultTypePrinterParser = 0;
Expand All @@ -32,19 +32,19 @@ def CIR_Dialect : Dialect {
let extraClassDeclaration = [{

// Names of CIR parameter attributes.
static StringRef getSExtAttrName() { return "cir.signext"; }
static StringRef getZExtAttrName() { return "cir.zeroext"; }
static llvm::StringRef getSExtAttrName() { return "cir.signext"; }
static llvm::StringRef getZExtAttrName() { return "cir.zeroext"; }

void registerAttributes();
void registerTypes();

Type parseType(DialectAsmParser &parser) const override;
void printType(Type type, DialectAsmPrinter &printer) const override;
mlir::Type parseType(mlir::DialectAsmParser &parser) const override;
void printType(mlir::Type type, mlir::DialectAsmPrinter &printer) const override;

Attribute parseAttribute(DialectAsmParser &parser,
Type type) const override;
mlir::Attribute parseAttribute(mlir::DialectAsmParser &parser,
mlir::Type type) const override;

void printAttribute(Attribute attr, DialectAsmPrinter &os) const override;
void printAttribute(mlir::Attribute attr, mlir::DialectAsmPrinter &os) const override;
}];
}

Expand Down
28 changes: 14 additions & 14 deletions clang/include/clang/CIR/Dialect/IR/CIROpenCLAttrs.td
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ def OpenCLKernelMetadataAttr
}];

let parameters = (ins
OptionalParameter<"ArrayAttr">:$work_group_size_hint,
OptionalParameter<"ArrayAttr">:$reqd_work_group_size,
OptionalParameter<"TypeAttr">:$vec_type_hint,
OptionalParameter<"mlir::ArrayAttr">:$work_group_size_hint,
OptionalParameter<"mlir::ArrayAttr">:$reqd_work_group_size,
OptionalParameter<"mlir::TypeAttr">:$vec_type_hint,
OptionalParameter<"std::optional<bool>">:$vec_type_hint_signedness,
OptionalParameter<"IntegerAttr">:$intel_reqd_sub_group_size
OptionalParameter<"mlir::IntegerAttr">:$intel_reqd_sub_group_size
);

let assemblyFormat = "`<` struct(params) `>`";
Expand All @@ -76,14 +76,14 @@ def OpenCLKernelMetadataAttr
let extraClassDefinition = [{
std::optional<bool> $cppClass::isSignedHint(mlir::Type hintQTy) {
// Only types in CIR carry signedness
if (!mlir::isa<mlir::cir::CIRDialect>(hintQTy.getDialect()))
if (!mlir::isa<cir::CIRDialect>(hintQTy.getDialect()))
return std::nullopt;

// See also clang::CodeGen::CodeGenFunction::EmitKernelMetadata
auto hintEltQTy = mlir::dyn_cast<mlir::cir::VectorType>(hintQTy);
auto hintEltQTy = mlir::dyn_cast<cir::VectorType>(hintQTy);
auto isCIRSignedIntType = [](mlir::Type t) {
return mlir::isa<mlir::cir::IntType>(t) &&
mlir::cast<mlir::cir::IntType>(t).isSigned();
return mlir::isa<cir::IntType>(t) &&
mlir::cast<cir::IntType>(t).isSigned();
};
return isCIRSignedIntType(hintQTy) ||
(hintEltQTy && isCIRSignedIntType(hintEltQTy.getEltType()));
Expand Down Expand Up @@ -134,12 +134,12 @@ def OpenCLKernelArgMetadataAttr
}];

let parameters = (ins
"ArrayAttr":$addr_space,
"ArrayAttr":$access_qual,
"ArrayAttr":$type,
"ArrayAttr":$base_type,
"ArrayAttr":$type_qual,
OptionalParameter<"ArrayAttr">:$name
"mlir::ArrayAttr":$addr_space,
"mlir::ArrayAttr":$access_qual,
"mlir::ArrayAttr":$type,
"mlir::ArrayAttr":$base_type,
"mlir::ArrayAttr":$type_qual,
OptionalParameter<"mlir::ArrayAttr">:$name
);

let assemblyFormat = "`<` struct(params) `>`";
Expand Down
Loading