[PATCH] D140361: [RISCV] Merge Masked and unMasked RVV manual codegen
Craig Topper via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 20 15:55:56 PST 2022
craig.topper added inline comments.
================
Comment at: clang/include/clang/Basic/riscv_vector.td:629
{
- if (DefaultPolicy == TAIL_AGNOSTIC)
- Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
- IntrinsicTypes = {ResultType, Ops[3]->getType()};
- Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
- Value *NewVL = Ops[2];
- Ops.erase(Ops.begin() + 2);
- llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
- llvm::Value *LoadValue = Builder.CreateCall(F, Ops, "");
- llvm::Value *V = Builder.CreateExtractValue(LoadValue, {0});
- // Store new_vl.
- clang::CharUnits Align =
- CGM.getNaturalPointeeTypeAlignment(E->getArg(1)->getType());
- llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {1});
- Builder.CreateStore(Val, Address(NewVL, Val->getType(), Align));
- return V;
- }
- }],
- MaskedManualCodegen = [{
- {
- // Move mask to right before vl.
- std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
- if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC)
- Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
- Ops.push_back(ConstantInt::get(Ops.back()->getType(), DefaultPolicy));
- IntrinsicTypes = {ResultType, Ops[4]->getType()};
+ if(IsMasked) {
+ // Move mask to right before vl.
----------------
space after `if`
================
Comment at: clang/include/clang/Basic/riscv_vector.td:649
+ clang::CharUnits Align;
+ if(IsMasked) {
+ Align = CGM.getNaturalPointeeTypeAlignment(
----------------
space after `if`
================
Comment at: clang/include/clang/Basic/riscv_vector.td:714
ManualCodegen = [{
- // Builtin: (ptr, value, vl). Intrinsic: (value, ptr, vl)
- std::swap(Ops[0], Ops[1]);
- Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType()->getPointerTo());
- IntrinsicTypes = {Ops[0]->getType(), Ops[2]->getType()};
- }],
- MaskedManualCodegen= [{
- // Builtin: (mask, ptr, value, vl). Intrinsic: (value, ptr, mask, vl)
- std::swap(Ops[0], Ops[2]);
+ if(IsMasked) {
+ // Builtin: (mask, ptr, value, vl). Intrinsic: (value, ptr, mask, vl)
----------------
space after `if`
================
Comment at: clang/include/clang/Basic/riscv_vector.td:722
Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType()->getPointerTo());
- IntrinsicTypes = {Ops[0]->getType(), Ops[3]->getType()};
+ if(IsMasked) {
+ IntrinsicTypes = {Ops[0]->getType(), Ops[3]->getType()};
----------------
space after `if`
Drop the curly brace since the bodies are single lines
================
Comment at: clang/include/clang/Basic/riscv_vector.td:754
ManualCodegen = [{
- // Builtin: (ptr, stride, value, vl). Intrinsic: (value, ptr, stride, vl)
- std::rotate(Ops.begin(), Ops.begin() + 2, Ops.begin() + 3);
- Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType()->getPointerTo());
- IntrinsicTypes = {Ops[0]->getType(), Ops[3]->getType()};
- }],
- MaskedManualCodegen= [{
- // Builtin: (mask, ptr, stride, value, vl). Intrinsic: (value, ptr, stride, mask, vl)
- std::swap(Ops[0], Ops[3]);
+ if(IsMasked) {
+ // Builtin: (mask, ptr, stride, value, vl). Intrinsic: (value, ptr, stride, mask, vl)
----------------
space after `if`
================
Comment at: clang/include/clang/Basic/riscv_vector.td:762
Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType()->getPointerTo());
- IntrinsicTypes = {Ops[0]->getType(), Ops[4]->getType()};
+ if(IsMasked) {
+ IntrinsicTypes = {Ops[0]->getType(), Ops[4]->getType()};
----------------
Space after `if`
Drop the curly braces since the bodies are single lines
================
Comment at: clang/include/clang/Basic/riscv_vector.td:1229
{
- // Builtin: (ptr, stride, val0, val1, ..., vl).
- // Intrinsic: (val0, val1, ..., ptr, stride, vl)
- std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
- IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
- assert(Ops.size() == NF + 3);
- }
- }],
- MaskedManualCodegen = [{
- {
- // Builtin: (mask, ptr, stride, val0, val1, ..., vl).
- // Intrinsic: (val0, val1, ..., ptr, stride, mask, vl)
- std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
- std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
+ if(IsMasked) {
+ // Builtin: (mask, ptr, stride, val0, val1, ..., vl).
----------------
Space after `if`
================
Comment at: clang/include/clang/Basic/riscv_vector.td:1278
+ } else {
+ // Builtin: (ptr, index, val0, val1, ..., vl)
+ // Intrinsic: (val0, val1, ..., ptr, index, vl)
----------------
Indentation looks wrong. The body is only indented once space from the else.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140361/new/
https://reviews.llvm.org/D140361
More information about the cfe-commits
mailing list