Re: [PATCH 3/5] opcode: add arity info

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 25/08/18 16:43, Luc Van Oostenryck wrote:
> The arity is a useful property of each opcode.
> 
> Add this information to the opcode definitions.
> 
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
> ---
>  opcode.c   |   3 +-
>  opcode.def | 164 ++++++++++++++++++++++++++---------------------------
>  opcode.h   |   3 +-
>  3 files changed, 86 insertions(+), 84 deletions(-)
> 
> diff --git a/opcode.c b/opcode.c
> index 67cede02d..0e41bc068 100644
> --- a/opcode.c
> +++ b/opcode.c
> @@ -23,11 +23,12 @@
>  #include "opcode.h"
>  
>  const struct opcode_table opcode_table[OP_LAST] = {
> -#define OPCODE(OP,NG,SW,TF)		\
> +#define OPCODE(OP,NG,SW,TF,N)		\
>  	[OP_##OP] = {			\
>  		.negate   = OP_##NG,	\
>  		.swap     = OP_##SW,	\
>  		.to_float = OP_##TF,	\
> +		.arity    = N,		\
>  	},
>  #define OPCODE_RANGE(OP,S,E)
>  #include "opcode.def"
> diff --git a/opcode.def b/opcode.def
> index 7add0b879..9a668bb34 100644
> --- a/opcode.def
> +++ b/opcode.def
> @@ -1,114 +1,114 @@
> -//	OPCODE		negated		swaped		float
> +//	OPCODE		negated   swaped    float

add an arity header?

>  
> -OPCODE(BADOP,		BADOP,		BADOP,		BADOP)
> +OPCODE(BADOP,    	BADOP,    BADOP,    BADOP, 0)

This table is just all over the place! (what tabstop are you
using? hint: the only correct answer is 8! ;-P ).

ATB,
Ramsay Jones

>  
>  /* Entry */
> -OPCODE(ENTRY,		BADOP,		BADOP,		BADOP)
> +OPCODE(ENTRY,		BADOP,    BADOP,    BADOP, 0)
>  
>  /* Terminator */
> -OPCODE(RET,		BADOP,		BADOP,		BADOP)
> -OPCODE(BR,		BADOP,		BADOP,		BADOP)
> -OPCODE(CBR,		BADOP,		BADOP,		BADOP)
> -OPCODE(SWITCH,		BADOP,		BADOP,		BADOP)
> -OPCODE(COMPUTEDGOTO,	BADOP,		BADOP,		BADOP)
> +OPCODE(RET,		BADOP,    BADOP,    BADOP, 1)
> +OPCODE(BR,		BADOP,    BADOP,    BADOP, 0)
> +OPCODE(CBR,		BADOP,    BADOP,    BADOP, 1)
> +OPCODE(SWITCH,		BADOP,    BADOP,    BADOP, 1)
> +OPCODE(COMPUTEDGOTO,	BADOP,    BADOP,    BADOP, 1)
>  OPCODE_RANGE(TERMINATOR, RET, COMPUTEDGOTO)
>  
>  /* Binary */
> -OPCODE(ADD,		BADOP,		BADOP,		FADD)
> -OPCODE(SUB,		BADOP,		BADOP,		FSUB)
> -OPCODE(MUL,		BADOP,		BADOP,		FMUL)
> -OPCODE(DIVU,		BADOP,		BADOP,		FDIV)
> -OPCODE(DIVS,		BADOP,		BADOP,		FDIV)
> -OPCODE(MODU,		BADOP,		BADOP,		BADOP)
> -OPCODE(MODS,		BADOP,		BADOP,		BADOP)
> -OPCODE(SHL,		BADOP,		BADOP,		BADOP)
> -OPCODE(LSR,		BADOP,		BADOP,		BADOP)
> -OPCODE(ASR,		BADOP,		BADOP,		BADOP)
> +OPCODE(ADD,		BADOP,    BADOP,    FADD,  2)
> +OPCODE(SUB,		BADOP,    BADOP,    FSUB,  2)
> +OPCODE(MUL,		BADOP,    BADOP,    FMUL,  2)
> +OPCODE(DIVU,		BADOP,    BADOP,    FDIV,  2)
> +OPCODE(DIVS,		BADOP,    BADOP,    FDIV,  2)
> +OPCODE(MODU,		BADOP,    BADOP,    BADOP, 2)
> +OPCODE(MODS,		BADOP,    BADOP,    BADOP, 2)
> +OPCODE(SHL,		BADOP,    BADOP,    BADOP, 2)
> +OPCODE(LSR,		BADOP,    BADOP,    BADOP, 2)
> +OPCODE(ASR,		BADOP,    BADOP,    BADOP, 2)
>  
>  /* Floating-point binops */
> -OPCODE(FADD,		BADOP,		BADOP,		BADOP)
> -OPCODE(FSUB,		BADOP,		BADOP,		BADOP)
> -OPCODE(FMUL,		BADOP,		BADOP,		BADOP)
> -OPCODE(FDIV,		BADOP,		BADOP,		BADOP)
> +OPCODE(FADD,		BADOP,    BADOP,    BADOP, 2)
> +OPCODE(FSUB,		BADOP,    BADOP,    BADOP, 2)
> +OPCODE(FMUL,		BADOP,    BADOP,    BADOP, 2)
> +OPCODE(FDIV,		BADOP,    BADOP,    BADOP, 2)
>  
>  /* Logical */
> -OPCODE(AND_BOOL,	BADOP,		BADOP,		BADOP)
> -OPCODE(OR_BOOL,		BADOP,		BADOP,		BADOP)
> -OPCODE(AND,		BADOP,		BADOP,		BADOP)
> -OPCODE(OR,		BADOP,		BADOP,		BADOP)
> -OPCODE(XOR,		BADOP,		BADOP,		BADOP)
> +OPCODE(AND_BOOL,	BADOP,    BADOP,    BADOP, 2)
> +OPCODE(OR_BOOL,		BADOP,    BADOP,    BADOP, 2)
> +OPCODE(AND,		BADOP,    BADOP,    BADOP, 2)
> +OPCODE(OR,		BADOP,    BADOP,    BADOP, 2)
> +OPCODE(XOR,		BADOP,    BADOP,    BADOP, 2)
>  OPCODE_RANGE(BINARY, ADD, XOR)
>  
>  /* floating-point comparison */
> -OPCODE(FCMP_ORD,	FCMP_UNO,	FCMP_ORD,	BADOP)
> -OPCODE(FCMP_OEQ,	FCMP_UNE,	FCMP_OEQ,	BADOP)
> -OPCODE(FCMP_ONE,	FCMP_UEQ,	FCMP_ONE,	BADOP)
> -OPCODE(FCMP_UEQ,	FCMP_ONE,	FCMP_UEQ,	BADOP)
> -OPCODE(FCMP_UNE,	FCMP_OEQ,	FCMP_UNE,	BADOP)
> -OPCODE(FCMP_OLT,	FCMP_UGE,	FCMP_OGT,	BADOP)
> -OPCODE(FCMP_OLE,	FCMP_UGT,	FCMP_OGE,	BADOP)
> -OPCODE(FCMP_OGE,	FCMP_ULT,	FCMP_OLE,	BADOP)
> -OPCODE(FCMP_OGT,	FCMP_ULE,	FCMP_OLT,	BADOP)
> -OPCODE(FCMP_ULT,	FCMP_OGE,	FCMP_UGT,	BADOP)
> -OPCODE(FCMP_ULE,	FCMP_OGT,	FCMP_UGE,	BADOP)
> -OPCODE(FCMP_UGE,	FCMP_OLT,	FCMP_ULE,	BADOP)
> -OPCODE(FCMP_UGT,	FCMP_OLE,	FCMP_ULT,	BADOP)
> -OPCODE(FCMP_UNO,	FCMP_ORD,	FCMP_UNO,	BADOP)
> +OPCODE(FCMP_ORD,	FCMP_UNO, FCMP_ORD, BADOP, 2)
> +OPCODE(FCMP_OEQ,	FCMP_UNE, FCMP_OEQ, BADOP, 2)
> +OPCODE(FCMP_ONE,	FCMP_UEQ, FCMP_ONE, BADOP, 2)
> +OPCODE(FCMP_UEQ,	FCMP_ONE, FCMP_UEQ, BADOP, 2)
> +OPCODE(FCMP_UNE,	FCMP_OEQ, FCMP_UNE, BADOP, 2)
> +OPCODE(FCMP_OLT,	FCMP_UGE, FCMP_OGT, BADOP, 2)
> +OPCODE(FCMP_OLE,	FCMP_UGT, FCMP_OGE, BADOP, 2)
> +OPCODE(FCMP_OGE,	FCMP_ULT, FCMP_OLE, BADOP, 2)
> +OPCODE(FCMP_OGT,	FCMP_ULE, FCMP_OLT, BADOP, 2)
> +OPCODE(FCMP_ULT,	FCMP_OGE, FCMP_UGT, BADOP, 2)
> +OPCODE(FCMP_ULE,	FCMP_OGT, FCMP_UGE, BADOP, 2)
> +OPCODE(FCMP_UGE,	FCMP_OLT, FCMP_ULE, BADOP, 2)
> +OPCODE(FCMP_UGT,	FCMP_OLE, FCMP_ULT, BADOP, 2)
> +OPCODE(FCMP_UNO,	FCMP_ORD, FCMP_UNO, BADOP, 2)
>  OPCODE_RANGE(FPCMP, FCMP_ORD, FCMP_UNO)
>  
>  /* Binary comparison */
> -OPCODE(SET_EQ,		SET_NE,		SET_EQ,		FCMP_OEQ)
> -OPCODE(SET_LT,		SET_GE,		SET_GT,		FCMP_OLT)
> -OPCODE(SET_LE,		SET_GT,		SET_GE,		FCMP_OLE)
> -OPCODE(SET_GE,		SET_LT,		SET_LE,		FCMP_OGE)
> -OPCODE(SET_GT,		SET_LE,		SET_LT,		FCMP_OGT)
> -OPCODE(SET_B,		SET_AE,		SET_A,		FCMP_OLT)
> -OPCODE(SET_BE,		SET_A,		SET_AE,		FCMP_OLE)
> -OPCODE(SET_AE,		SET_B,		SET_BE,		FCMP_OGE)
> -OPCODE(SET_A,		SET_BE,		SET_B,		FCMP_OGT)
> -OPCODE(SET_NE,		SET_EQ,		SET_NE,		FCMP_UNE)
> +OPCODE(SET_EQ,		SET_NE,   SET_EQ,   FCMP_OEQ, 2)
> +OPCODE(SET_LT,		SET_GE,   SET_GT,   FCMP_OLT, 2)
> +OPCODE(SET_LE,		SET_GT,   SET_GE,   FCMP_OLE, 2)
> +OPCODE(SET_GE,		SET_LT,   SET_LE,   FCMP_OGE, 2)
> +OPCODE(SET_GT,		SET_LE,   SET_LT,   FCMP_OGT, 2)
> +OPCODE(SET_B,		SET_AE,   SET_A,    FCMP_OLT, 2)
> +OPCODE(SET_BE,		SET_A,    SET_AE,   FCMP_OLE, 2)
> +OPCODE(SET_AE,		SET_B,    SET_BE,   FCMP_OGE, 2)
> +OPCODE(SET_A,		SET_BE,   SET_B,    FCMP_OGT, 2)
> +OPCODE(SET_NE,		SET_EQ,   SET_NE,   FCMP_UNE, 2)
>  OPCODE_RANGE(BINCMP, SET_EQ, SET_NE)
>  
>  /* Uni */
> -OPCODE(NOT,		BADOP,		BADOP,		BADOP)
> -OPCODE(NEG,		BADOP,		BADOP,		FNEG)
> -OPCODE(FNEG,		BADOP,		BADOP,		BADOP)
> -OPCODE(TRUNC,		BADOP,		BADOP,		BADOP)
> -OPCODE(ZEXT,		BADOP,		BADOP,		BADOP)
> -OPCODE(SEXT,		BADOP,		BADOP,		BADOP)
> -OPCODE(FCVTU,		BADOP,		BADOP,		BADOP)
> -OPCODE(FCVTS,		BADOP,		BADOP,		BADOP)
> -OPCODE(UCVTF,		BADOP,		BADOP,		BADOP)
> -OPCODE(SCVTF,		BADOP,		BADOP,		BADOP)
> -OPCODE(FCVTF,		BADOP,		BADOP,		BADOP)
> -OPCODE(UTPTR,		BADOP,		BADOP,		BADOP)
> -OPCODE(PTRTU,		BADOP,		BADOP,		BADOP)
> -OPCODE(PTRCAST,		BADOP,		BADOP,		BADOP)
> +OPCODE(NOT,		BADOP,    BADOP,    BADOP, 1)
> +OPCODE(NEG,		BADOP,    BADOP,    FNEG,  1)
> +OPCODE(FNEG,		BADOP,    BADOP,    BADOP, 1)
> +OPCODE(TRUNC,		BADOP,    BADOP,    BADOP, 1)
> +OPCODE(ZEXT,		BADOP,    BADOP,    BADOP, 1)
> +OPCODE(SEXT,		BADOP,    BADOP,    BADOP, 1)
> +OPCODE(FCVTU,		BADOP,    BADOP,    BADOP, 1)
> +OPCODE(FCVTS,		BADOP,    BADOP,    BADOP, 1)
> +OPCODE(UCVTF,		BADOP,    BADOP,    BADOP, 1)
> +OPCODE(SCVTF,		BADOP,    BADOP,    BADOP, 1)
> +OPCODE(FCVTF,		BADOP,    BADOP,    BADOP, 1)
> +OPCODE(UTPTR,		BADOP,    BADOP,    BADOP, 1)
> +OPCODE(PTRTU,		BADOP,    BADOP,    BADOP, 1)
> +OPCODE(PTRCAST,		BADOP,    BADOP,    BADOP, 1)
>  OPCODE_RANGE(UNOP, NOT, PTRCAST)
> -OPCODE(SYMADDR,		BADOP,		BADOP,		BADOP)
> -OPCODE(SLICE,		BADOP,		BADOP,		BADOP)
> +OPCODE(SYMADDR,		BADOP,    BADOP,    BADOP, 1)
> +OPCODE(SLICE,		BADOP,    BADOP,    BADOP, 1)
>  
>  /* Select - three input values */
> -OPCODE(SEL,		BADOP,		BADOP,		BADOP)
> +OPCODE(SEL,		BADOP,    BADOP,    BADOP, 3)
>  
>  /* Memory */
> -OPCODE(LOAD,		BADOP,		BADOP,		BADOP)
> -OPCODE(STORE,		BADOP,		BADOP,		BADOP)
> +OPCODE(LOAD,		BADOP,    BADOP,    BADOP, 1)
> +OPCODE(STORE,		BADOP,    BADOP,    BADOP, 1)
>  
>  /* Other */
> -OPCODE(PHISOURCE,	BADOP,		BADOP,		BADOP)
> -OPCODE(PHI,		BADOP,		BADOP,		BADOP)
> -OPCODE(SETVAL,		BADOP,		BADOP,		BADOP)
> -OPCODE(SETFVAL,		BADOP,		BADOP,		BADOP)
> -OPCODE(CALL,		BADOP,		BADOP,		BADOP)
> -OPCODE(INLINED_CALL,	BADOP,		BADOP,		BADOP)
> -OPCODE(NOP,		BADOP,		BADOP,		BADOP)
> -OPCODE(DEATHNOTE,	BADOP,		BADOP,		BADOP)
> -OPCODE(ASM,		BADOP,		BADOP,		BADOP)
> +OPCODE(PHISOURCE,	BADOP,    BADOP,    BADOP, 1)
> +OPCODE(PHI,		BADOP,    BADOP,    BADOP, 0)
> +OPCODE(SETVAL,		BADOP,    BADOP,    BADOP, 0)
> +OPCODE(SETFVAL,		BADOP,    BADOP,    BADOP, 0)
> +OPCODE(CALL,		BADOP,    BADOP,    BADOP, 1)
> +OPCODE(INLINED_CALL,	BADOP,    BADOP,    BADOP, 0)
> +OPCODE(NOP,		BADOP,    BADOP,    BADOP, 0)
> +OPCODE(DEATHNOTE,	BADOP,    BADOP,    BADOP, 0)
> +OPCODE(ASM,		BADOP,    BADOP,    BADOP, 0)
>  
>  /* Sparse tagging (line numbers, context, whatever) */
> -OPCODE(CONTEXT,		BADOP,		BADOP,		BADOP)
> -OPCODE(RANGE,		BADOP,		BADOP,		BADOP)
> +OPCODE(CONTEXT,		BADOP,    BADOP,    BADOP, 0)
> +OPCODE(RANGE,		BADOP,    BADOP,    BADOP, 3)
>  
>  /* Needed to translate SSA back to normal form */
> -OPCODE(COPY,		BADOP,		BADOP,		BADOP)
> +OPCODE(COPY,		BADOP,    BADOP,    BADOP, 1)
> diff --git a/opcode.h b/opcode.h
> index 171df36fc..14ac2ffcc 100644
> --- a/opcode.h
> +++ b/opcode.h
> @@ -4,7 +4,7 @@
>  #include "symbol.h"
>  
>  enum opcode {
> -#define OPCODE(OP,NG,SW,TF)	OP_##OP,
> +#define OPCODE(OP,NG,SW,TF,N)  OP_##OP,
>  #define OPCODE_RANGE(OP,S,E)	OP_##OP = OP_##S, OP_##OP##_END = OP_##E,
>  #include "opcode.def"
>  #undef  OPCODE
> @@ -16,6 +16,7 @@ extern const struct opcode_table {
>  	int	negate:8;
>  	int	swap:8;
>  	int	to_float:8;
> +	unsigned int arity:2;
>  } opcode_table[];
>  
>  
> 



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux