@@ -25,30 +25,32 @@ export function emitMul(ctx: EmitContext, type: string, lhs: string, rhs: string
2525 return temp ;
2626}
2727
28+ const FMATH = "nnan ninf nsz arcp contract reassoc afn" ;
29+
2830export function emitFAdd ( ctx : EmitContext , lhs : string , rhs : string ) : string {
2931 const temp = ctx . nextTemp ( ) ;
30- ctx . emit ( `${ temp } = fadd double ${ lhs } , ${ rhs } ` ) ;
32+ ctx . emit ( `${ temp } = fadd ${ FMATH } double ${ lhs } , ${ rhs } ` ) ;
3133 ctx . setVariableType ( temp , "double" ) ;
3234 return temp ;
3335}
3436
3537export function emitFSub ( ctx : EmitContext , lhs : string , rhs : string ) : string {
3638 const temp = ctx . nextTemp ( ) ;
37- ctx . emit ( `${ temp } = fsub double ${ lhs } , ${ rhs } ` ) ;
39+ ctx . emit ( `${ temp } = fsub ${ FMATH } double ${ lhs } , ${ rhs } ` ) ;
3840 ctx . setVariableType ( temp , "double" ) ;
3941 return temp ;
4042}
4143
4244export function emitFMul ( ctx : EmitContext , lhs : string , rhs : string ) : string {
4345 const temp = ctx . nextTemp ( ) ;
44- ctx . emit ( `${ temp } = fmul double ${ lhs } , ${ rhs } ` ) ;
46+ ctx . emit ( `${ temp } = fmul ${ FMATH } double ${ lhs } , ${ rhs } ` ) ;
4547 ctx . setVariableType ( temp , "double" ) ;
4648 return temp ;
4749}
4850
4951export function emitFDiv ( ctx : EmitContext , lhs : string , rhs : string ) : string {
5052 const temp = ctx . nextTemp ( ) ;
51- ctx . emit ( `${ temp } = fdiv double ${ lhs } , ${ rhs } ` ) ;
53+ ctx . emit ( `${ temp } = fdiv ${ FMATH } double ${ lhs } , ${ rhs } ` ) ;
5254 ctx . setVariableType ( temp , "double" ) ;
5355 return temp ;
5456}
@@ -62,14 +64,14 @@ export function emitSRem(ctx: EmitContext, type: string, lhs: string, rhs: strin
6264
6365export function emitFRem ( ctx : EmitContext , lhs : string , rhs : string ) : string {
6466 const temp = ctx . nextTemp ( ) ;
65- ctx . emit ( `${ temp } = frem double ${ lhs } , ${ rhs } ` ) ;
67+ ctx . emit ( `${ temp } = frem ${ FMATH } double ${ lhs } , ${ rhs } ` ) ;
6668 ctx . setVariableType ( temp , "double" ) ;
6769 return temp ;
6870}
6971
7072export function emitFNeg ( ctx : EmitContext , value : string ) : string {
7173 const temp = ctx . nextTemp ( ) ;
72- ctx . emit ( `${ temp } = fneg double ${ value } ` ) ;
74+ ctx . emit ( `${ temp } = fneg ${ FMATH } double ${ value } ` ) ;
7375 ctx . setVariableType ( temp , "double" ) ;
7476 return temp ;
7577}
0 commit comments