Skip to content

Commit 96e055d

Browse files
authored
Handle builtin FP types in SILBuilder::appendOperandTypeName
The following builder method doesn't handle floating point operands yet. ```cpp BuiltinInst *createBuiltinBinaryFunction(SILLocation Loc, StringRef Name, SILType OpdTy, SILType ResultTy, ArrayRef<SILValue> Args) ``` This patch adds support for calling this method with floating point operands. ```cpp SILValue x = ...; // $Builtin.FPIEEE32 B.createBuiltinBinaryFunction(loc, "fmul", x->getType(), x->getType(), { x, x }) ``` Corresponding SIL: ``` %0 = builtin "fmul_FPIEEE32"(%x : $Builtin.FPIEEE32, %x : $Builtin.FPIEEE32) : $Builtin.FPIEEE32 ```
1 parent 9f75e4a commit 96e055d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

include/swift/SIL/SILBuilder.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2099,6 +2099,18 @@ class SILBuilder {
20992099
unsigned NumBits = BuiltinIntTy->getWidth().getFixedWidth();
21002100
Name += "_Int" + llvm::utostr(NumBits);
21012101
}
2102+
}
2103+
else if (auto BuiltinFloatTy =
2104+
dyn_cast<BuiltinFloatType>(OpdTy.getASTType())) {
2105+
Name += "_FP";
2106+
switch (BuiltinFloatTy->getFPKind()) {
2107+
case BuiltinFloatType::IEEE16: Name += "IEEE16"; break;
2108+
case BuiltinFloatType::IEEE32: Name += "IEEE32"; break;
2109+
case BuiltinFloatType::IEEE64: Name += "IEEE64"; break;
2110+
case BuiltinFloatType::IEEE80: Name += "IEEE80"; break;
2111+
case BuiltinFloatType::IEEE128: Name += "IEEE128"; break;
2112+
case BuiltinFloatType::PPC128: Name += "PPC128"; break;
2113+
}
21022114
} else {
21032115
assert(OpdTy.getASTType() == getASTContext().TheRawPointerType);
21042116
Name += "_RawPointer";

0 commit comments

Comments
 (0)