Skip to content

Commit e24a2f2

Browse files
committed
Support for Float literals
1 parent db6e8a9 commit e24a2f2

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

include/swift/WALASupport/InstrKindInfoGetter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class InstrKindInfoGetter {
4747
jobject handleIntegerLiteralInst();
4848
jobject handleStringLiteralInst();
4949
jobject handleConstStringLiteralInst();
50+
jobject handleFloatLiteralInst();
5051
jobject handleProjectBoxInst();
5152
jobject handleDebugValueInst();
5253
jobject handleFunctionRefInst();

lib/WALASupport/InstrKindInfoGetter.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,19 @@ jobject InstrKindInfoGetter::handleIntegerLiteralInst() {
225225
return node;
226226
}
227227

228+
jobject InstrKindInfoGetter::handleFloatLiteralInst() {
229+
if (outs != NULL) {
230+
*outs << "<< FloatLiteralInst >>" << "\n";
231+
}
232+
FloatLiteralInst* castInst = cast<FloatLiteralInst>(instr);
233+
APFloat value = castInst->getValue();
234+
bool APFLosesInfo;
235+
value.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven, &APFLosesInfo);
236+
jobject node = (*wala)->makeConstant(value.convertToDouble());
237+
nodeMap->insert(std::make_pair(castInst, node));
238+
return node;
239+
}
240+
228241
jobject InstrKindInfoGetter::handleStringLiteralInst() {
229242
// ValueKind indentifier
230243
if (outs != NULL) {
@@ -813,7 +826,7 @@ SILInstructionKind InstrKindInfoGetter::get() {
813826
}
814827

815828
case SILInstructionKind::FloatLiteralInst: {
816-
*outs << "<< FloatLiteralInst >>" << "\n";
829+
node = handleFloatLiteralInst();
817830
break;
818831
}
819832

0 commit comments

Comments
 (0)