[clang] [AArch64][Clang] Refactor code to emit SVE & SME builtins (PR #70662)
Sander de Smalen via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 31 03:46:47 PDT 2023
================
@@ -9893,24 +9888,40 @@ Value *CodeGenFunction::FormSVEBuiltinResult(Value *Call) {
return Call;
}
-Value *CodeGenFunction::EmitAArch64SVEBuiltinExpr(unsigned BuiltinID,
- const CallExpr *E) {
+void CodeGenFunction::GetAArch64SVEProcessedOperands(
+ unsigned BuiltinID, const CallExpr *E, SmallVectorImpl<Value *> &Ops,
+ SVETypeFlags TypeFlags) {
// Find out if any arguments are required to be integer constant expressions.
unsigned ICEArguments = 0;
ASTContext::GetBuiltinTypeError Error;
getContext().GetBuiltinType(BuiltinID, Error, &ICEArguments);
assert(Error == ASTContext::GE_None && "Should not codegen an error");
- llvm::Type *Ty = ConvertType(E->getType());
- if (BuiltinID >= SVE::BI__builtin_sve_reinterpret_s8_s8 &&
- BuiltinID <= SVE::BI__builtin_sve_reinterpret_f64_f64) {
- Value *Val = EmitScalarExpr(E->getArg(0));
- return EmitSVEReinterpret(Val, Ty);
- }
+ // Tuple set/get only requires one insert/extract vector, which is
+ // created by EmitSVETupleSetOrGet.
+ bool IsTupleGetOrSet = TypeFlags.isTupleSet() || TypeFlags.isTupleGet();
- llvm::SmallVector<Value *, 4> Ops;
for (unsigned i = 0, e = E->getNumArgs(); i != e; i++) {
- if ((ICEArguments & (1 << i)) == 0)
+ bool IsICE = ICEArguments & (1 << i);
+ if (!IsTupleGetOrSet && !IsICE) {
----------------
sdesmalen-arm wrote:
nit: While we're refactoring this, can this loop be rewritten a bit, e.g.
```
for (unsigned i = 0, e = E->getNumArgs(); i != e; i++) {
bool IsICE = ICEArguments & (1 << i);
Value *Arg = EmitScalarExpr(E->getArg(i));
if (!isa<ScalableVectorType>(Arg->getType())) {
if (IsICE || !IsTupleGetOrSet)
Ops.push_back(Arg);
continue;
}
auto *VTy = cast<ScalableVectorType>(Arg->getType())
/* rest of the code here */
}
```
https://github.com/llvm/llvm-project/pull/70662
More information about the cfe-commits
mailing list