Skip to content

Commit

Permalink
just use one version of getExtendedElementVectorType
Browse files Browse the repository at this point in the history
  • Loading branch information
ghehg committed Oct 3, 2024
1 parent d1899ee commit 089b7b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
23 changes: 3 additions & 20 deletions clang/lib/CIR/CodeGen/CIRGenBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,30 +385,13 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy {
llvm_unreachable("NYI");
}

static mlir::cir::IntType checkAndGetIntEltTy(mlir::cir::VectorType vt) {
mlir::cir::VectorType getExtendedElementVectorType(mlir::cir::VectorType vt,
bool isSigned = false) {
auto elementTy =
mlir::dyn_cast_or_null<mlir::cir::IntType>(vt.getEltType());
assert(elementTy && "expected int vector");
return elementTy;
}

/// This function `getExtendedElementVectorType` is used to
/// get the vector type of extended int element type for a given vector type.
/// The extended element type has the signess specified.
mlir::cir::VectorType getExtendedElementVectorType(mlir::cir::VectorType vt,
bool isSigned) {
return mlir::cir::VectorType::get(
getContext(), getExtendedIntTy(checkAndGetIntEltTy(vt), isSigned),
vt.getSize());
}

/// This version of `getExtendedElementVectorType` is used when signess of
/// extended element type is the same as that of the original element type.
mlir::cir::VectorType getExtendedElementVectorType(mlir::cir::VectorType vt) {
mlir::cir::IntType elementTy = checkAndGetIntEltTy(vt);
return mlir::cir::VectorType::get(
getContext(), getExtendedIntTy(elementTy, elementTy.isSigned()),
vt.getSize());
getContext(), getExtendedIntTy(elementTy, isSigned), vt.getSize());
}

mlir::cir::LongDoubleType
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2232,7 +2232,8 @@ mlir::Value CIRGenFunction::buildCommonNeonBuiltinExpr(
default:
break;
case NEON::BI__builtin_neon_vmovn_v: {
mlir::cir::VectorType qTy = builder.getExtendedElementVectorType(vTy);
mlir::cir::VectorType qTy = builder.getExtendedElementVectorType(
vTy, mlir::cast<mlir::cir::IntType>(vTy.getEltType()).isSigned());
ops[0] = builder.createBitcast(ops[0], qTy);
// It really is truncation in this context.
// In CIR, integral cast op supports vector of int type truncating.
Expand Down

0 comments on commit 089b7b5

Please sign in to comment.