Last active
September 12, 2015 22:15
-
-
Save nkaretnikov/d4c58d9a0fe66f27267a to your computer and use it in GitHub Desktop.
subWordC#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NotMain.foo_info: | |
_cvi: | |
_cvk: | |
subq $1,%rsi | |
setc %al | |
movzbl %al,%eax | |
movq %rax,%r14 | |
movq %rsi,%rbx | |
jmp *(%rbp) | |
.size NotMain.foo_info, .-NotMain.foo_info |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- a/compiler/nativeGen/X86/CodeGen.hs | |
+++ b/compiler/nativeGen/X86/CodeGen.hs | |
@@ -2065,10 +2065,12 @@ genCCall _ is32Bit target dest_regs args = do | |
ADC format (OpImm (ImmInteger 0)) (OpReg reg_h) | |
return code | |
_ -> panic "genCCall: Wrong number of arguments/results for add2" | |
+ (PrimTarget (MO_SubWordC width), [res_r, res_c]) -> | |
+ addSubIntC platform SUB_CC (Just . SUB_CC) CARRY width res_r res_c args | |
(PrimTarget (MO_AddIntC width), [res_r, res_c]) -> | |
- addSubIntC platform ADD_CC (Just . ADD_CC) width res_r res_c args | |
+ addSubIntC platform ADD_CC (Just . ADD_CC) OFLO width res_r res_c args | |
(PrimTarget (MO_SubIntC width), [res_r, res_c]) -> | |
- addSubIntC platform SUB_CC (const Nothing) width res_r res_c args | |
+ addSubIntC platform SUB_CC (const Nothing) OFLO width res_r res_c args | |
(PrimTarget (MO_U_Mul2 width), [res_h, res_l]) -> | |
case args of | |
[arg_x, arg_y] -> | |
@@ -2122,7 +2124,7 @@ genCCall _ is32Bit target dest_regs args = do | |
divOp _ _ _ _ _ _ _ | |
= panic "genCCall: Wrong number of results for divOp" | |
- addSubIntC platform instr mrevinstr width res_r res_c [arg_x, arg_y] | |
+ addSubIntC platform instr mrevinstr cond width res_r res_c [arg_x, arg_y] | |
= do let format = intFormat width | |
rCode <- anyReg =<< trivialCode width (instr format) | |
(mrevinstr format) arg_x arg_y | |
@@ -2130,10 +2132,10 @@ genCCall _ is32Bit target dest_regs args = do | |
let reg_c = getRegisterReg platform True (CmmLocal res_c) | |
reg_r = getRegisterReg platform True (CmmLocal res_r) | |
code = rCode reg_r `snocOL` | |
- SETCC OFLO (OpReg reg_tmp) `snocOL` | |
+ SETCC cond (OpReg reg_tmp) `snocOL` | |
MOVZxL II8 (OpReg reg_tmp) (OpReg reg_c) | |
return code | |
- addSubIntC _ _ _ _ _ _ _ | |
+ addSubIntC _ _ _ _ _ _ _ _ | |
= panic "genCCall: Wrong number of arguments/results for addSubIntC" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE MagicHash #-} | |
{-# LANGUAGE UnboxedTuples #-} | |
module NotMain where | |
import GHC.Base | |
foo x = subWordC# 1## |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE MagicHash #-} | |
{-# LANGUAGE UnboxedTuples #-} | |
module NotMain where | |
import GHC.Base | |
main :: IO () | |
main = | |
let (# w, i #) = subWordC# 1## 3## | |
in print (W# w, I# i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_cJC: | |
movq $stg_bh_upd_frame_info,-16(%rbp) | |
movq %rax,-8(%rbp) | |
movl $3,%eax | |
subq $1,%rax | |
setc %bl | |
movzbl %bl,%ebx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE MagicHash #-} | |
{-# LANGUAGE UnboxedTuples #-} | |
module Main where | |
import GHC.Base | |
main :: IO () | |
main = | |
let (# w, i #) = subWordC# 3## 1## | |
in print (W# w, I# i) | |
-- % ./SubWordMainRev -- INSERT -- | |
-- (18446744073709551614,1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_cL5: | |
movq $stg_bh_upd_frame_info,-16(%rbp) | |
movq %rax,-8(%rbp) | |
movl $1,%eax | |
subq $3,%rax | |
setc %bl | |
movzbl %bl,%ebx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment