Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /sml/trunk/src/MLRISC/alpha/instructions/alphaInstr.sml
ViewVC logotype

View of /sml/trunk/src/MLRISC/alpha/instructions/alphaInstr.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1003 - (download) (annotate)
Fri Dec 7 02:45:32 2001 UTC (18 years, 1 month ago) by george
File size: 14154 byte(s)
Changed the representation of instructions from being fully abstract
to being partially concrete. That is to say:

  from
	type instruction

  to
	type instr				(* machine instruction *)

	datatype instruction =
	    LIVE of {regs: C.cellset, spilled: C.cellset}
          | KILL of {regs: C.cellset, spilled: C.cellset}
          | COPYXXX of {k: CB.cellkind, dst: CB.cell list, src: CB.cell list}
          | ANNOTATION of {i: instruction, a: Annotations.annotation}
          | INSTR of instr

This makes the handling of certain special instructions that appear on
all architectures easier and uniform.

LIVE and KILL say that a list of registers are live or killed at the
program point where they appear. No spill code is generated when an
element of the 'regs' field is spilled, but the register is moved to
the 'spilled' (which is present, more for debugging than anything else).

LIVE replaces the (now deprecated) DEFFREG instruction on the alpha.
We used to generate:

	DEFFREG f1
	f1 := f2 + f3
        trapb

but now generate:

	f1 := f2 + f3
	trapb
	LIVE {regs=[f1,f2,f3], spilled=[]}

Furthermore, the DEFFREG (hack) required that all floating point instruction
use all registers mentioned in the instruction. Therefore f1 := f2 + f3,
defines f1 and uses [f1,f2,f3]! This hack is no longer required resulting
in a cleaner alpha implementation. (Hopefully, intel will not get rid of
this architecture).

COPYXXX is intended to replace the parallel COPY and FCOPY  available on
all the architectures. This will result in further simplification of the
register allocator that must be aware of them for coalescing purposes, and
will also simplify certain aspects of the machine description that provides
callbacks related to parallel copies.

ANNOTATION should be obvious, and now INSTR represents the honest to God
machine instruction set!

The <arch>/instructions/<arch>Instr.sml files define certain utility
functions for making porting easier -- essentially converting upper case
to lower case. All machine instructions (of type instr) are in upper case,
and the lower case form generates an MLRISC instruction. For example on
the alpha we have:

  datatype instr =
     LDA of {r:cell, b:cell, d:operand}
   | ...

  val lda : {r:cell, b:cell, d:operand} -> instruction
    ...

where lda is just (INSTR o LDA), etc.
(*
 * WARNING: This file was automatically generated by MDLGen (v3.0)
 * from the machine description file "alpha/alpha.mdl".
 * DO NOT EDIT this file directly
 *)


signature ALPHAINSTR =
sig
   structure C : ALPHACELLS
   structure CB : CELLS_BASIS
   structure T : MLTREE
   structure Constant: CONSTANT
   structure Region : REGION
      sharing Constant = T.Constant
      sharing Region = T.Region
   datatype ea =
     Direct of CellsBasis.cell
   | FDirect of CellsBasis.cell
   | Displace of {base:CellsBasis.cell, disp:int}
   datatype operand =
     REGop of CellsBasis.cell
   | IMMop of int
   | HILABop of T.labexp
   | LOLABop of T.labexp
   | LABop of T.labexp
   datatype branch =
     BR
   | BLBC
   | BEQ
   | BLT
   | BLE
   | BLBS
   | BNE
   | BGE
   | BGT
   datatype fbranch =
     FBEQ
   | FBLT
   | FBLE
   | FBNE
   | FBGE
   | FBGT
   datatype load =
     LDB
   | LDW
   | LDBU
   | LDWU
   | LDL
   | LDL_L
   | LDQ
   | LDQ_L
   | LDQ_U
   datatype store =
     STB
   | STW
   | STL
   | STQ
   | STQ_U
   datatype fload =
     LDF
   | LDG
   | LDS
   | LDT
   datatype fstore =
     STF
   | STG
   | STS
   | STT
   datatype operate =
     ADDL
   | ADDQ
   | CMPBGE
   | CMPEQ
   | CMPLE
   | CMPLT
   | CMPULE
   | CMPULT
   | SUBL
   | SUBQ
   | S4ADDL
   | S4ADDQ
   | S4SUBL
   | S4SUBQ
   | S8ADDL
   | S8ADDQ
   | S8SUBL
   | S8SUBQ
   | AND
   | BIC
   | BIS
   | EQV
   | ORNOT
   | XOR
   | EXTBL
   | EXTLH
   | EXTLL
   | EXTQH
   | EXTQL
   | EXTWH
   | EXTWL
   | INSBL
   | INSLH
   | INSLL
   | INSQH
   | INSQL
   | INSWH
   | INSWL
   | MSKBL
   | MSKLH
   | MSKLL
   | MSKQH
   | MSKQL
   | MSKWH
   | MSKWL
   | SLL
   | SRA
   | SRL
   | ZAP
   | ZAPNOT
   | MULL
   | MULQ
   | UMULH
   datatype cmove =
     CMOVEQ
   | CMOVLBC
   | CMOVLBS
   | CMOVGE
   | CMOVGT
   | CMOVLE
   | CMOVLT
   | CMOVNE
   datatype pseudo_op =
     DIVL
   | DIVLU
   | DIVQ
   | DIVQU
   | REML
   | REMLU
   | REMQ
   | REMQU
   datatype operateV =
     ADDLV
   | ADDQV
   | SUBLV
   | SUBQV
   | MULLV
   | MULQV
   datatype funary =
     CVTLQ
   | CVTQL
   | CVTQLSV
   | CVTQLV
   | CVTQS
   | CVTQSC
   | CVTQT
   | CVTQTC
   | CVTTS
   | CVTTSC
   | CVTST
   | CVTSTS
   | CVTTQ
   | CVTTQC
   datatype foperate =
     CPYS
   | CPYSE
   | CPYSN
   | MF_FPCR
   | MT_FPCR
   | CMPTEQ
   | CMPTLT
   | CMPTLE
   | CMPTUN
   | CMPTEQSU
   | CMPTLTSU
   | CMPTLESU
   | CMPTUNSU
   | ADDS
   | ADDT
   | DIVS
   | DIVT
   | MULS
   | MULT
   | SUBS
   | SUBT
   datatype fcmove =
     FCMOVEQ
   | FCMOVGE
   | FCMOVGT
   | FCMOVLE
   | FCMOVLT
   | FCMOVNE
   datatype foperateV =
     ADDSSUD
   | ADDSSU
   | ADDTSUD
   | ADDTSU
   | DIVSSUD
   | DIVSSU
   | DIVTSUD
   | DIVTSU
   | MULSSUD
   | MULSSU
   | MULTSUD
   | MULTSU
   | SUBSSUD
   | SUBSSU
   | SUBTSUD
   | SUBTSU
   datatype osf_user_palcode =
     BPT
   | BUGCHK
   | CALLSYS
   | GENTRAP
   | IMB
   | RDUNIQUE
   | WRUNIQUE
   type addressing_mode = CellsBasis.cell * operand
   datatype instr =
     LDA of {r:CellsBasis.cell, b:CellsBasis.cell, d:operand}
   | LDAH of {r:CellsBasis.cell, b:CellsBasis.cell, d:operand}
   | LOAD of {ldOp:load, r:CellsBasis.cell, b:CellsBasis.cell, d:operand, mem:Region.region}
   | STORE of {stOp:store, r:CellsBasis.cell, b:CellsBasis.cell, d:operand, 
        mem:Region.region}
   | FLOAD of {ldOp:fload, r:CellsBasis.cell, b:CellsBasis.cell, d:operand, 
        mem:Region.region}
   | FSTORE of {stOp:fstore, r:CellsBasis.cell, b:CellsBasis.cell, d:operand, 
        mem:Region.region}
   | JMPL of {r:CellsBasis.cell, b:CellsBasis.cell, d:int} * Label.label list
   | JSR of {r:CellsBasis.cell, b:CellsBasis.cell, d:int, defs:C.cellset, uses:C.cellset, 
        cutsTo:Label.label list, mem:Region.region}
   | BSR of {r:CellsBasis.cell, lab:Label.label, defs:C.cellset, uses:C.cellset, 
        cutsTo:Label.label list, mem:Region.region}
   | RET of {r:CellsBasis.cell, b:CellsBasis.cell, d:int}
   | BRANCH of {b:branch, r:CellsBasis.cell, lab:Label.label}
   | FBRANCH of {b:fbranch, f:CellsBasis.cell, lab:Label.label}
   | OPERATE of {oper:operate, ra:CellsBasis.cell, rb:operand, rc:CellsBasis.cell}
   | OPERATEV of {oper:operateV, ra:CellsBasis.cell, rb:operand, rc:CellsBasis.cell}
   | CMOVE of {oper:cmove, ra:CellsBasis.cell, rb:operand, rc:CellsBasis.cell}
   | PSEUDOARITH of {oper:pseudo_op, ra:CellsBasis.cell, rb:operand, rc:CellsBasis.cell, 
        tmps:C.cellset}
   | COPY of {dst:(CellsBasis.cell) list, src:(CellsBasis.cell) list, impl:instruction list option ref, 
        tmp:ea option}
   | FCOPY of {dst:(CellsBasis.cell) list, src:(CellsBasis.cell) list, impl:instruction list option ref, 
        tmp:ea option}
   | FUNARY of {oper:funary, fb:CellsBasis.cell, fc:CellsBasis.cell}
   | FOPERATE of {oper:foperate, fa:CellsBasis.cell, fb:CellsBasis.cell, fc:CellsBasis.cell}
   | FOPERATEV of {oper:foperateV, fa:CellsBasis.cell, fb:CellsBasis.cell, 
        fc:CellsBasis.cell}
   | FCMOVE of {oper:fcmove, fa:CellsBasis.cell, fb:CellsBasis.cell, fc:CellsBasis.cell}
   | TRAPB
   | CALL_PAL of {code:osf_user_palcode, def:C.cellset, use:C.cellset}
   | SOURCE of {}
   | SINK of {}
   | PHI of {}
   and instruction =
     LIVE of {regs: C.cellset, spilled: C.cellset}
   | KILL of {regs: C.cellset, spilled: C.cellset}
   | COPYXXX of {k: CB.cellkind, dst: CB.cell list, src: CB.cell list}
   | ANNOTATION of {i:instruction, a:Annotations.annotation}
   | INSTR of instr
   val lda : {r:CellsBasis.cell, b:CellsBasis.cell, d:operand} -> instruction
   val ldah : {r:CellsBasis.cell, b:CellsBasis.cell, d:operand} -> instruction
   val load : {ldOp:load, r:CellsBasis.cell, b:CellsBasis.cell, d:operand, 
      mem:Region.region} -> instruction
   val store : {stOp:store, r:CellsBasis.cell, b:CellsBasis.cell, d:operand, 
      mem:Region.region} -> instruction
   val fload : {ldOp:fload, r:CellsBasis.cell, b:CellsBasis.cell, d:operand, 
      mem:Region.region} -> instruction
   val fstore : {stOp:fstore, r:CellsBasis.cell, b:CellsBasis.cell, d:operand, 
      mem:Region.region} -> instruction
   val jmpl : {r:CellsBasis.cell, b:CellsBasis.cell, d:int} * Label.label list -> instruction
   val jsr : {r:CellsBasis.cell, b:CellsBasis.cell, d:int, defs:C.cellset, 
      uses:C.cellset, cutsTo:Label.label list, mem:Region.region} -> instruction
   val bsr : {r:CellsBasis.cell, lab:Label.label, defs:C.cellset, uses:C.cellset, 
      cutsTo:Label.label list, mem:Region.region} -> instruction
   val ret : {r:CellsBasis.cell, b:CellsBasis.cell, d:int} -> instruction
   val branch : {b:branch, r:CellsBasis.cell, lab:Label.label} -> instruction
   val fbranch : {b:fbranch, f:CellsBasis.cell, lab:Label.label} -> instruction
   val operate : {oper:operate, ra:CellsBasis.cell, rb:operand, rc:CellsBasis.cell} -> instruction
   val operatev : {oper:operateV, ra:CellsBasis.cell, rb:operand, rc:CellsBasis.cell} -> instruction
   val cmove : {oper:cmove, ra:CellsBasis.cell, rb:operand, rc:CellsBasis.cell} -> instruction
   val pseudoarith : {oper:pseudo_op, ra:CellsBasis.cell, rb:operand, rc:CellsBasis.cell, 
      tmps:C.cellset} -> instruction
   val copy : {dst:(CellsBasis.cell) list, src:(CellsBasis.cell) list, impl:instruction list option ref, 
      tmp:ea option} -> instruction
   val fcopy : {dst:(CellsBasis.cell) list, src:(CellsBasis.cell) list, impl:instruction list option ref, 
      tmp:ea option} -> instruction
   val funary : {oper:funary, fb:CellsBasis.cell, fc:CellsBasis.cell} -> instruction
   val foperate : {oper:foperate, fa:CellsBasis.cell, fb:CellsBasis.cell, fc:CellsBasis.cell} -> instruction
   val foperatev : {oper:foperateV, fa:CellsBasis.cell, fb:CellsBasis.cell, 
      fc:CellsBasis.cell} -> instruction
   val fcmove : {oper:fcmove, fa:CellsBasis.cell, fb:CellsBasis.cell, fc:CellsBasis.cell} -> instruction
   val trapb : instruction
   val call_pal : {code:osf_user_palcode, def:C.cellset, use:C.cellset} -> instruction
   val source : {} -> instruction
   val sink : {} -> instruction
   val phi : {} -> instruction
end

functor AlphaInstr(T: MLTREE
                  ) : ALPHAINSTR =
struct
   structure C = AlphaCells
   structure CB = CellsBasis
   structure T = T
   structure Region = T.Region
   structure Constant = T.Constant
   datatype ea =
     Direct of CellsBasis.cell
   | FDirect of CellsBasis.cell
   | Displace of {base:CellsBasis.cell, disp:int}
   datatype operand =
     REGop of CellsBasis.cell
   | IMMop of int
   | HILABop of T.labexp
   | LOLABop of T.labexp
   | LABop of T.labexp
   datatype branch =
     BR
   | BLBC
   | BEQ
   | BLT
   | BLE
   | BLBS
   | BNE
   | BGE
   | BGT
   datatype fbranch =
     FBEQ
   | FBLT
   | FBLE
   | FBNE
   | FBGE
   | FBGT
   datatype load =
     LDB
   | LDW
   | LDBU
   | LDWU
   | LDL
   | LDL_L
   | LDQ
   | LDQ_L
   | LDQ_U
   datatype store =
     STB
   | STW
   | STL
   | STQ
   | STQ_U
   datatype fload =
     LDF
   | LDG
   | LDS
   | LDT
   datatype fstore =
     STF
   | STG
   | STS
   | STT
   datatype operate =
     ADDL
   | ADDQ
   | CMPBGE
   | CMPEQ
   | CMPLE
   | CMPLT
   | CMPULE
   | CMPULT
   | SUBL
   | SUBQ
   | S4ADDL
   | S4ADDQ
   | S4SUBL
   | S4SUBQ
   | S8ADDL
   | S8ADDQ
   | S8SUBL
   | S8SUBQ
   | AND
   | BIC
   | BIS
   | EQV
   | ORNOT
   | XOR
   | EXTBL
   | EXTLH
   | EXTLL
   | EXTQH
   | EXTQL
   | EXTWH
   | EXTWL
   | INSBL
   | INSLH
   | INSLL
   | INSQH
   | INSQL
   | INSWH
   | INSWL
   | MSKBL
   | MSKLH
   | MSKLL
   | MSKQH
   | MSKQL
   | MSKWH
   | MSKWL
   | SLL
   | SRA
   | SRL
   | ZAP
   | ZAPNOT
   | MULL
   | MULQ
   | UMULH
   datatype cmove =
     CMOVEQ
   | CMOVLBC
   | CMOVLBS
   | CMOVGE
   | CMOVGT
   | CMOVLE
   | CMOVLT
   | CMOVNE
   datatype pseudo_op =
     DIVL
   | DIVLU
   | DIVQ
   | DIVQU
   | REML
   | REMLU
   | REMQ
   | REMQU
   datatype operateV =
     ADDLV
   | ADDQV
   | SUBLV
   | SUBQV
   | MULLV
   | MULQV
   datatype funary =
     CVTLQ
   | CVTQL
   | CVTQLSV
   | CVTQLV
   | CVTQS
   | CVTQSC
   | CVTQT
   | CVTQTC
   | CVTTS
   | CVTTSC
   | CVTST
   | CVTSTS
   | CVTTQ
   | CVTTQC
   datatype foperate =
     CPYS
   | CPYSE
   | CPYSN
   | MF_FPCR
   | MT_FPCR
   | CMPTEQ
   | CMPTLT
   | CMPTLE
   | CMPTUN
   | CMPTEQSU
   | CMPTLTSU
   | CMPTLESU
   | CMPTUNSU
   | ADDS
   | ADDT
   | DIVS
   | DIVT
   | MULS
   | MULT
   | SUBS
   | SUBT
   datatype fcmove =
     FCMOVEQ
   | FCMOVGE
   | FCMOVGT
   | FCMOVLE
   | FCMOVLT
   | FCMOVNE
   datatype foperateV =
     ADDSSUD
   | ADDSSU
   | ADDTSUD
   | ADDTSU
   | DIVSSUD
   | DIVSSU
   | DIVTSUD
   | DIVTSU
   | MULSSUD
   | MULSSU
   | MULTSUD
   | MULTSU
   | SUBSSUD
   | SUBSSU
   | SUBTSUD
   | SUBTSU
   datatype osf_user_palcode =
     BPT
   | BUGCHK
   | CALLSYS
   | GENTRAP
   | IMB
   | RDUNIQUE
   | WRUNIQUE
   type addressing_mode = CellsBasis.cell * operand
   datatype instr =
     LDA of {r:CellsBasis.cell, b:CellsBasis.cell, d:operand}
   | LDAH of {r:CellsBasis.cell, b:CellsBasis.cell, d:operand}
   | LOAD of {ldOp:load, r:CellsBasis.cell, b:CellsBasis.cell, d:operand, mem:Region.region}
   | STORE of {stOp:store, r:CellsBasis.cell, b:CellsBasis.cell, d:operand, 
        mem:Region.region}
   | FLOAD of {ldOp:fload, r:CellsBasis.cell, b:CellsBasis.cell, d:operand, 
        mem:Region.region}
   | FSTORE of {stOp:fstore, r:CellsBasis.cell, b:CellsBasis.cell, d:operand, 
        mem:Region.region}
   | JMPL of {r:CellsBasis.cell, b:CellsBasis.cell, d:int} * Label.label list
   | JSR of {r:CellsBasis.cell, b:CellsBasis.cell, d:int, defs:C.cellset, uses:C.cellset, 
        cutsTo:Label.label list, mem:Region.region}
   | BSR of {r:CellsBasis.cell, lab:Label.label, defs:C.cellset, uses:C.cellset, 
        cutsTo:Label.label list, mem:Region.region}
   | RET of {r:CellsBasis.cell, b:CellsBasis.cell, d:int}
   | BRANCH of {b:branch, r:CellsBasis.cell, lab:Label.label}
   | FBRANCH of {b:fbranch, f:CellsBasis.cell, lab:Label.label}
   | OPERATE of {oper:operate, ra:CellsBasis.cell, rb:operand, rc:CellsBasis.cell}
   | OPERATEV of {oper:operateV, ra:CellsBasis.cell, rb:operand, rc:CellsBasis.cell}
   | CMOVE of {oper:cmove, ra:CellsBasis.cell, rb:operand, rc:CellsBasis.cell}
   | PSEUDOARITH of {oper:pseudo_op, ra:CellsBasis.cell, rb:operand, rc:CellsBasis.cell, 
        tmps:C.cellset}
   | COPY of {dst:(CellsBasis.cell) list, src:(CellsBasis.cell) list, impl:instruction list option ref, 
        tmp:ea option}
   | FCOPY of {dst:(CellsBasis.cell) list, src:(CellsBasis.cell) list, impl:instruction list option ref, 
        tmp:ea option}
   | FUNARY of {oper:funary, fb:CellsBasis.cell, fc:CellsBasis.cell}
   | FOPERATE of {oper:foperate, fa:CellsBasis.cell, fb:CellsBasis.cell, fc:CellsBasis.cell}
   | FOPERATEV of {oper:foperateV, fa:CellsBasis.cell, fb:CellsBasis.cell, 
        fc:CellsBasis.cell}
   | FCMOVE of {oper:fcmove, fa:CellsBasis.cell, fb:CellsBasis.cell, fc:CellsBasis.cell}
   | TRAPB
   | CALL_PAL of {code:osf_user_palcode, def:C.cellset, use:C.cellset}
   | SOURCE of {}
   | SINK of {}
   | PHI of {}
   and instruction =
     LIVE of {regs: C.cellset, spilled: C.cellset}
   | KILL of {regs: C.cellset, spilled: C.cellset}
   | COPYXXX of {k: CB.cellkind, dst: CB.cell list, src: CB.cell list}
   | ANNOTATION of {i:instruction, a:Annotations.annotation}
   | INSTR of instr
   val lda = INSTR o LDA
   and ldah = INSTR o LDAH
   and load = INSTR o LOAD
   and store = INSTR o STORE
   and fload = INSTR o FLOAD
   and fstore = INSTR o FSTORE
   and jmpl = INSTR o JMPL
   and jsr = INSTR o JSR
   and bsr = INSTR o BSR
   and ret = INSTR o RET
   and branch = INSTR o BRANCH
   and fbranch = INSTR o FBRANCH
   and operate = INSTR o OPERATE
   and operatev = INSTR o OPERATEV
   and cmove = INSTR o CMOVE
   and pseudoarith = INSTR o PSEUDOARITH
   and copy = INSTR o COPY
   and fcopy = INSTR o FCOPY
   and funary = INSTR o FUNARY
   and foperate = INSTR o FOPERATE
   and foperatev = INSTR o FOPERATEV
   and fcmove = INSTR o FCMOVE
   and trapb = INSTR TRAPB
   and call_pal = INSTR o CALL_PAL
   and source = INSTR o SOURCE
   and sink = INSTR o SINK
   and phi = INSTR o PHI
end


root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0