Merge branch 'master' of git://factorcode.org/git/factor
commit
a618407bda
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
||||||
! (c)2010 Joe Groff bsd license
|
! (c)2010 Joe Groff bsd license
|
||||||
USING: accessors arrays combinators io kernel math math.parser
|
USING: accessors arrays combinators io io.streams.string kernel
|
||||||
roles sequences strings variants words ;
|
math math.parser roles sequences strings variants words ;
|
||||||
FROM: roles => TUPLE: ;
|
FROM: roles => TUPLE: ;
|
||||||
IN: cuda.ptx
|
IN: cuda.ptx
|
||||||
|
|
||||||
|
@ -62,6 +62,7 @@ TUPLE: ptx-variable
|
||||||
{ parameter ?integer }
|
{ parameter ?integer }
|
||||||
{ dim dim }
|
{ dim dim }
|
||||||
{ initializer ?string } ;
|
{ initializer ?string } ;
|
||||||
|
UNION: ?ptx-variable POSTPONE: f ptx-variable ;
|
||||||
|
|
||||||
TUPLE: ptx-predicate
|
TUPLE: ptx-predicate
|
||||||
{ negated? boolean }
|
{ negated? boolean }
|
||||||
|
@ -79,7 +80,7 @@ TUPLE: ptx-entry
|
||||||
body ;
|
body ;
|
||||||
|
|
||||||
TUPLE: ptx-func < ptx-entry
|
TUPLE: ptx-func < ptx-entry
|
||||||
{ return ptx-variable } ;
|
{ return ?ptx-variable } ;
|
||||||
|
|
||||||
TUPLE: ptx-directive ;
|
TUPLE: ptx-directive ;
|
||||||
|
|
||||||
|
@ -241,7 +242,7 @@ TUPLE: cnot < ptx-2op-instruction ;
|
||||||
TUPLE: copysign < ptx-3op-instruction ;
|
TUPLE: copysign < ptx-3op-instruction ;
|
||||||
TUPLE: cos <{ ptx-2op-instruction ptx-float-env } ;
|
TUPLE: cos <{ ptx-2op-instruction ptx-float-env } ;
|
||||||
TUPLE: cvt < ptx-2op-instruction
|
TUPLE: cvt < ptx-2op-instruction
|
||||||
{ rounding-mode ?ptx-rounding-mode }
|
{ round ?ptx-rounding-mode }
|
||||||
{ ftz? boolean }
|
{ ftz? boolean }
|
||||||
{ sat? boolean }
|
{ sat? boolean }
|
||||||
{ dest-type ptx-type } ;
|
{ dest-type ptx-type } ;
|
||||||
|
@ -253,7 +254,7 @@ TUPLE: ex2 <{ ptx-2op-instruction ptx-float-env } ;
|
||||||
TUPLE: exit < ptx-instruction ;
|
TUPLE: exit < ptx-instruction ;
|
||||||
TUPLE: fma <{ ptx-mad-instruction ptx-float-env } ;
|
TUPLE: fma <{ ptx-mad-instruction ptx-float-env } ;
|
||||||
TUPLE: isspacep < ptx-instruction
|
TUPLE: isspacep < ptx-instruction
|
||||||
{ storage-space ?ptx-storage-space }
|
{ storage-space ptx-storage-space }
|
||||||
{ dest string }
|
{ dest string }
|
||||||
{ a string } ;
|
{ a string } ;
|
||||||
TUPLE: ld < ptx-ldst-instruction ;
|
TUPLE: ld < ptx-ldst-instruction ;
|
||||||
|
@ -331,15 +332,23 @@ TUPLE: xor < ptx-3op-instruction ;
|
||||||
GENERIC: ptx-element-label ( elt -- label )
|
GENERIC: ptx-element-label ( elt -- label )
|
||||||
M: object ptx-element-label drop f ;
|
M: object ptx-element-label drop f ;
|
||||||
|
|
||||||
|
GENERIC: ptx-semicolon? ( elt -- ? )
|
||||||
|
M: object ptx-semicolon? drop t ;
|
||||||
|
M: ptx-target ptx-semicolon? drop f ;
|
||||||
|
M: ptx-entry ptx-semicolon? drop f ;
|
||||||
|
M: ptx-func ptx-semicolon? drop f ;
|
||||||
|
M: .file ptx-semicolon? drop f ;
|
||||||
|
M: .loc ptx-semicolon? drop f ;
|
||||||
|
|
||||||
GENERIC: (write-ptx-element) ( elt -- )
|
GENERIC: (write-ptx-element) ( elt -- )
|
||||||
|
|
||||||
: write-ptx-element ( elt -- )
|
: write-ptx-element ( elt -- )
|
||||||
dup ptx-element-label [ write ":" write ] when*
|
dup ptx-element-label [ write ":" write ] when*
|
||||||
"\t" write (write-ptx-element)
|
"\t" write dup (write-ptx-element)
|
||||||
";" print ;
|
ptx-semicolon? [ ";" print ] [ nl ] if ;
|
||||||
|
|
||||||
: write-ptx ( ptx -- )
|
: write-ptx ( ptx -- )
|
||||||
"\t.version " write dup version>> write ";" print
|
"\t.version " write dup version>> print
|
||||||
dup target>> write-ptx-element
|
dup target>> write-ptx-element
|
||||||
body>> [ write-ptx-element ] each ;
|
body>> [ write-ptx-element ] each ;
|
||||||
|
|
||||||
|
@ -399,9 +408,9 @@ M: ptx-variable (write-ptx-element)
|
||||||
"\t}" write ;
|
"\t}" write ;
|
||||||
|
|
||||||
: write-entry ( entry -- )
|
: write-entry ( entry -- )
|
||||||
dup name>> write " " write
|
dup name>> write
|
||||||
dup params>> [ write-params ] when* nl
|
dup params>> [ " " write write-params ] when* nl
|
||||||
dup directives>> [ (write-ptx-element) ] each nl
|
dup directives>> [ (write-ptx-element) nl ] each
|
||||||
dup body>> write-body
|
dup body>> write-body
|
||||||
drop ;
|
drop ;
|
||||||
|
|
||||||
|
@ -538,7 +547,7 @@ M: bar.red (write-ptx-element)
|
||||||
dup b>> [ ", " write write ] when*
|
dup b>> [ ", " write write ] when*
|
||||||
", " write c>> write ;
|
", " write c>> write ;
|
||||||
M: bar.sync (write-ptx-element)
|
M: bar.sync (write-ptx-element)
|
||||||
"bar.arrive " write-insn
|
"bar.sync " write-insn
|
||||||
dup a>> write
|
dup a>> write
|
||||||
dup b>> [ ", " write write ] when*
|
dup b>> [ ", " write write ] when*
|
||||||
drop ;
|
drop ;
|
||||||
|
@ -554,15 +563,16 @@ M: bfind (write-ptx-element)
|
||||||
write-2op ;
|
write-2op ;
|
||||||
M: bra (write-ptx-element)
|
M: bra (write-ptx-element)
|
||||||
"bra" write-insn
|
"bra" write-insn
|
||||||
dup write-uni
|
dup write-uni " " write
|
||||||
" " write target>> write ;
|
target>> write ;
|
||||||
M: brev (write-ptx-element)
|
M: brev (write-ptx-element)
|
||||||
"brev" write-insn
|
"brev" write-insn
|
||||||
write-2op ;
|
write-2op ;
|
||||||
M: brkpt (write-ptx-element)
|
M: brkpt (write-ptx-element)
|
||||||
"brkpt" write-insn drop ;
|
"brkpt" write-insn drop ;
|
||||||
M: call (write-ptx-element)
|
M: call (write-ptx-element)
|
||||||
"call" write-insn " " write
|
"call" write-insn
|
||||||
|
dup write-uni " " write
|
||||||
dup return>> [ "(" write write "), " write ] when*
|
dup return>> [ "(" write write "), " write ] when*
|
||||||
dup target>> write
|
dup target>> write
|
||||||
dup params>> [ ", (" write ", " join write ")" write ] unless-empty
|
dup params>> [ ", (" write ", " join write ")" write ] unless-empty
|
||||||
|
@ -582,7 +592,7 @@ M: cos (write-ptx-element)
|
||||||
write-2op ;
|
write-2op ;
|
||||||
M: cvt (write-ptx-element)
|
M: cvt (write-ptx-element)
|
||||||
"cvt" write-insn
|
"cvt" write-insn
|
||||||
dup rounding-mode>> (write-ptx-element)
|
dup round>> (write-ptx-element)
|
||||||
dup write-ftz
|
dup write-ftz
|
||||||
dup write-sat
|
dup write-sat
|
||||||
dup dest-type>> (write-ptx-element)
|
dup dest-type>> (write-ptx-element)
|
||||||
|
@ -676,12 +686,17 @@ M: prefetchu (write-ptx-element)
|
||||||
" " write a>> write ;
|
" " write a>> write ;
|
||||||
M: prmt (write-ptx-element)
|
M: prmt (write-ptx-element)
|
||||||
"prmt" write-insn
|
"prmt" write-insn
|
||||||
dup mode>> (write-ptx-element)
|
dup type>> (write-ptx-element)
|
||||||
write-4op ;
|
dup mode>> (write-ptx-element) " " write
|
||||||
|
dup dest>> write ", " write
|
||||||
|
dup a>> write ", " write
|
||||||
|
dup b>> write ", " write
|
||||||
|
dup c>> write
|
||||||
|
drop ;
|
||||||
M: rcp (write-ptx-element)
|
M: rcp (write-ptx-element)
|
||||||
"rcp" write-insn
|
"rcp" write-insn
|
||||||
dup write-float-env
|
dup write-float-env
|
||||||
write-3op ;
|
write-2op ;
|
||||||
M: red (write-ptx-element)
|
M: red (write-ptx-element)
|
||||||
"red" write-insn
|
"red" write-insn
|
||||||
dup storage-space>> (write-ptx-element)
|
dup storage-space>> (write-ptx-element)
|
||||||
|
@ -749,10 +764,15 @@ M: testp (write-ptx-element)
|
||||||
"testp" write-insn
|
"testp" write-insn
|
||||||
dup op>> (write-ptx-element)
|
dup op>> (write-ptx-element)
|
||||||
write-2op ;
|
write-2op ;
|
||||||
|
M: trap (write-ptx-element)
|
||||||
|
"trap" write-insn drop ;
|
||||||
M: vote (write-ptx-element)
|
M: vote (write-ptx-element)
|
||||||
"vote" write-insn
|
"vote" write-insn
|
||||||
dup mode>> (write-ptx-element)
|
dup mode>> (write-ptx-element)
|
||||||
write-2op ;
|
write-2op ;
|
||||||
M: xor (write-ptx-element)
|
M: xor (write-ptx-element)
|
||||||
"or" write-insn
|
"xor" write-insn
|
||||||
write-3op ;
|
write-3op ;
|
||||||
|
|
||||||
|
: ptx>string ( ptx -- string )
|
||||||
|
[ write-ptx ] with-string-writer ;
|
||||||
|
|
Loading…
Reference in New Issue