Skip to content

Commit

Permalink
[Clang][RISCV] bfloat uses 'y' instead of 'b' (#76575)
Browse files Browse the repository at this point in the history
Builtins.def says that bfloat should be represented by the 'y'
character, not the 'b' character. The 'b' character is specified to
represent boolean. The implementation currently uses 'b' correctly for
boolean and incorrectly re-uses 'b' for bfloat.

This was not caught since no builtins are emitted in
build/tools/clang/include/clang/Basic/riscv_sifive_vector_builtins.inc.
Don't know that we can test this without creating builtins that expose
this issue, although I'm not sure we really want to do that.
  • Loading branch information
michaelmaitland committed Dec 30, 2023
1 parent 81cedac commit fa8347f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/riscv_sifive_vector.td
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ multiclass RVVVFWMACCBuiltinSet<list<list<string>> suffixes_prototypes> {
Name = NAME,
HasMasked = false,
Log2LMUL = [-2, -1, 0, 1, 2] in
defm NAME : RVVOutOp1Op2BuiltinSet<NAME, "b", suffixes_prototypes>;
defm NAME : RVVOutOp1Op2BuiltinSet<NAME, "y", suffixes_prototypes>;
}

multiclass RVVVQMACCDODBuiltinSet<list<list<string>> suffixes_prototypes> {
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/riscv_vector_common.td
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
// x: float16_t (half)
// f: float32_t (float)
// d: float64_t (double)
// b: bfloat16_t (bfloat16)
// y: bfloat16_t (bfloat16)
//
// This way, given an LMUL, a record with a TypeRange "sil" will cause the
// definition of 3 builtins. Each type "t" in the TypeRange (in this example
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Support/RISCVVIntrinsicUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void RVVType::initBuiltinStr() {
}
break;
case ScalarTypeKind::BFloat:
BuiltinStr += "b";
BuiltinStr += "y";
break;
default:
llvm_unreachable("ScalarType is invalid!");
Expand Down
2 changes: 1 addition & 1 deletion clang/utils/TableGen/RISCVVEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ static BasicType ParseBasicType(char c) {
case 'd':
return BasicType::Float64;
break;
case 'b':
case 'y':
return BasicType::BFloat16;
break;
default:
Expand Down

0 comments on commit fa8347f

Please sign in to comment.