[llvm] [AMDGPU][MC] Implement fft and rotate modes for ds_swizzle_b32 (PR #108064)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 11 03:14:11 PDT 2024
================
@@ -8141,6 +8143,56 @@ AMDGPUAsmParser::parseSwizzleBitmaskPerm(int64_t &Imm) {
return true;
}
+bool AMDGPUAsmParser::parseSwizzleFFT(int64_t &Imm) {
+ using namespace llvm::AMDGPU::Swizzle;
+
+ if (!skipToken(AsmToken::Comma, "expected a comma"))
+ return false;
+
+ SMLoc Loc = getLoc();
+
+ int64_t Type;
+
+ if (!parseExpr(Type))
+ return false;
+
+ if (Type != FFT_NO_SWIZZLE && Type != FFT_SWIZZLE_00 &&
+ Type != FFT_SWIZZLE_10) {
+ const std::string ErrMsg = "invalid FFT swizzle type: must be " +
+ std::to_string(FFT_SWIZZLE_00) + ", " +
+ std::to_string(FFT_SWIZZLE_10) + ", or " +
+ std::to_string(FFT_NO_SWIZZLE);
+ Error(Loc, ErrMsg);
+ return false;
+ }
+
+ Imm = FFT_MODE_ENC | Type;
+ return true;
+}
+
+bool AMDGPUAsmParser::parseSwizzleRotate(int64_t &Imm) {
+ using namespace llvm::AMDGPU::Swizzle;
+
+ SMLoc Loc;
+ int64_t Direction;
+
+ if (!parseSwizzleOperand(Direction, 0, 1,
+ "direction must be 0 (left) or 1 (right)", Loc))
+ return false;
+
+ int64_t RotateSize;
+ const std::string ErrorMsg =
+ "number of threads to rotate must be in the interval [0," +
+ std::to_string(ROTATE_MAX_SIZE) + "]";
----------------
arsenm wrote:
shouldn't need to pre-create the error string, also these all use Twine?
https://github.com/llvm/llvm-project/pull/108064
More information about the llvm-commits
mailing list