Skip to content
Snippets Groups Projects
asm.go 62 KiB
Newer Older
  • Learn to ignore specific revisions
  • 		return 0x07020 << 15 // stx.b
    	case AMOVH:
    		return 0x07028 << 15 // stx.h
    	case AMOVW:
    		return 0x07030 << 15 // stx.w
    	case AMOVV:
    		return 0x07038 << 15 // stx.d
    	case -AMOVF:
    		return 0x07060 << 15 // fldx.s
    	case -AMOVD:
    		return 0x07068 << 15 // fldx.d
    	case AMOVF:
    		return 0x07070 << 15 // fstx.s
    	case AMOVD:
    		return 0x07078 << 15 // fstx.d
    
    	}
    
    	if a < 0 {
    		c.ctxt.Diag("bad rrr opcode -%v", -a)
    	} else {
    		c.ctxt.Diag("bad rrr opcode %v", a)
    	}
    	return 0
    }
    
    func (c *ctxt0) oprr(a obj.As) uint32 {
    	switch a {
    	case ACLO:
    		return 0x4 << 10
    	case ACLZ:
    		return 0x5 << 10
    	case ACPUCFG:
    		return 0x1b << 10
    	case ARDTIMELW:
    		return 0x18 << 10
    	case ARDTIMEHW:
    		return 0x19 << 10
    	case ARDTIMED:
    		return 0x1a << 10
    
    	case ATRUNCFV:
    		return 0x46a9 << 10
    	case ATRUNCDV:
    		return 0x46aa << 10
    	case ATRUNCFW:
    		return 0x46a1 << 10
    	case ATRUNCDW:
    		return 0x46a2 << 10
    	case AMOVFV:
    		return 0x46c9 << 10
    	case AMOVDV:
    		return 0x46ca << 10
    	case AMOVVF:
    		return 0x4746 << 10
    	case AMOVVD:
    		return 0x474a << 10
    	case AMOVFW:
    		return 0x46c1 << 10
    	case AMOVDW:
    		return 0x46c2 << 10
    	case AMOVWF:
    		return 0x4744 << 10
    	case AMOVDF:
    		return 0x4646 << 10
    	case AMOVWD:
    		return 0x4748 << 10
    	case AMOVFD:
    		return 0x4649 << 10
    	case AABSF:
    		return 0x4501 << 10
    	case AABSD:
    		return 0x4502 << 10
    	case AMOVF:
    		return 0x4525 << 10
    	case AMOVD:
    		return 0x4526 << 10
    	case ANEGF:
    		return 0x4505 << 10
    	case ANEGD:
    		return 0x4506 << 10
    	case ASQRTF:
    		return 0x4511 << 10
    	case ASQRTD:
    		return 0x4512 << 10
    
    	case AFCLASSF:
    		return 0x450d << 10 // fclass.s
    	case AFCLASSD:
    		return 0x450e << 10 // fclass.d
    
    	case AFFINTFW:
    		return 0x4744 << 10 // ffint.s.w
    	case AFFINTFV:
    		return 0x4746 << 10 // ffint.s.l
    	case AFFINTDW:
    		return 0x4748 << 10 // ffint.d.w
    	case AFFINTDV:
    		return 0x474a << 10 // ffint.d.l
    	case AFTINTWF:
    		return 0x46c1 << 10 // ftint.w.s
    	case AFTINTWD:
    		return 0x46c2 << 10 // ftint.w.d
    	case AFTINTVF:
    		return 0x46c9 << 10 // ftint.l.s
    	case AFTINTVD:
    		return 0x46ca << 10 // ftint.l.d
    
    	case AFTINTRMWF:
    		return 0x4681 << 10 // ftintrm.w.s
    	case AFTINTRMWD:
    		return 0x4682 << 10 // ftintrm.w.d
    	case AFTINTRMVF:
    		return 0x4689 << 10 // ftintrm.l.s
    	case AFTINTRMVD:
    		return 0x468a << 10 // ftintrm.l.d
    	case AFTINTRPWF:
    		return 0x4691 << 10 // ftintrp.w.s
    	case AFTINTRPWD:
    		return 0x4692 << 10 // ftintrp.w.d
    	case AFTINTRPVF:
    		return 0x4699 << 10 // ftintrp.l.s
    	case AFTINTRPVD:
    		return 0x469a << 10 // ftintrp.l.d
    	case AFTINTRZWF:
    		return 0x46a1 << 10 // ftintrz.w.s
    	case AFTINTRZWD:
    		return 0x46a2 << 10 // ftintrz.w.d
    	case AFTINTRZVF:
    		return 0x46a9 << 10 // ftintrz.l.s
    	case AFTINTRZVD:
    		return 0x46aa << 10 // ftintrz.l.d
    	case AFTINTRNEWF:
    		return 0x46b1 << 10 // ftintrne.w.s
    	case AFTINTRNEWD:
    		return 0x46b2 << 10 // ftintrne.w.d
    	case AFTINTRNEVF:
    		return 0x46b9 << 10 // ftintrne.l.s
    	case AFTINTRNEVD:
    		return 0x46ba << 10 // ftintrne.l.d
    
    func (c *ctxt0) opi(a obj.As) uint32 {
    	switch a {
    	case ASYSCALL:
    		return 0x56 << 15
    	case ABREAK:
    		return 0x54 << 15
    	case ADBAR:
    		return 0x70e4 << 15
    	}
    
    	c.ctxt.Diag("bad ic opcode %v", a)
    
    	return 0
    }
    
    
    func (c *ctxt0) opir(a obj.As) uint32 {
    	switch a {
    	case ALU12IW:
    		return 0x0a << 25
    	case ALU32ID:
    		return 0x0b << 25
    
    	case APCADDU12I:
    		return 0x0e << 25
    	}
    	return 0
    }
    
    func (c *ctxt0) opirr(a obj.As) uint32 {
    	switch a {
    	case AADD, AADDU:
    		return 0x00a << 22
    	case ASGT:
    		return 0x008 << 22
    	case ASGTU:
    		return 0x009 << 22
    	case AAND:
    		return 0x00d << 22
    	case AOR:
    		return 0x00e << 22
    	case ALU52ID:
    		return 0x00c << 22
    	case AXOR:
    		return 0x00f << 22
    	case ASLL:
    		return 0x00081 << 15
    	case ASRL:
    		return 0x00089 << 15
    	case ASRA:
    		return 0x00091 << 15
    
    	case AROTR:
    		return 0x00099 << 15
    
    	case AADDV:
    		return 0x00b << 22
    	case AADDVU:
    		return 0x00b << 22
    
    	case AJMP:
    		return 0x14 << 26
    	case AJAL,
    		obj.ADUFFZERO,
    		obj.ADUFFCOPY:
    		return 0x15 << 26
    
    	case AJIRL:
    		return 0x13 << 26
    	case ABLTU:
    		return 0x1a << 26
    	case ABLT, ABLTZ, ABGTZ:
    		return 0x18 << 26
    	case ABGEU:
    		return 0x1b << 26
    	case ABGE, ABGEZ, ABLEZ:
    		return 0x19 << 26
    
    	case -ABEQ: // beqz
    		return 0x10 << 26
    	case -ABNE: // bnez
    		return 0x11 << 26
    
    	case ABEQ:
    		return 0x16 << 26
    	case ABNE:
    		return 0x17 << 26
    	case ABFPT:
    		return 0x12<<26 | 0x1<<8
    	case ABFPF:
    		return 0x12<<26 | 0x0<<8
    
    	case AMOVB,
    		AMOVBU:
    		return 0x0a4 << 22
    	case AMOVH,
    		AMOVHU:
    		return 0x0a5 << 22
    	case AMOVW,
    		AMOVWU:
    		return 0x0a6 << 22
    	case AMOVV:
    		return 0x0a7 << 22
    	case AMOVF:
    		return 0x0ad << 22
    	case AMOVD:
    		return 0x0af << 22
    	case -AMOVB:
    		return 0x0a0 << 22
    	case -AMOVBU:
    		return 0x0a8 << 22
    	case -AMOVH:
    		return 0x0a1 << 22
    	case -AMOVHU:
    		return 0x0a9 << 22
    	case -AMOVW:
    		return 0x0a2 << 22
    	case -AMOVWU:
    		return 0x0aa << 22
    	case -AMOVV:
    		return 0x0a3 << 22
    	case -AMOVF:
    		return 0x0ac << 22
    	case -AMOVD:
    		return 0x0ae << 22
    
    
    	case -ALL:
    		return 0x020 << 24
    	case -ALLV:
    		return 0x022 << 24
    	case ASC:
    		return 0x021 << 24
    	case ASCV:
    		return 0x023 << 24
    	}
    
    	if a < 0 {
    		c.ctxt.Diag("bad irr opcode -%v", -a)
    	} else {
    		c.ctxt.Diag("bad irr opcode %v", a)
    	}
    	return 0
    }
    
    
    func (c *ctxt0) opirir(a obj.As) uint32 {
    	switch a {
    	case ABSTRINSW:
    		return 0x3<<21 | 0x0<<15 // bstrins.w
    	case ABSTRINSV:
    		return 0x2 << 22 // bstrins.d
    	case ABSTRPICKW:
    		return 0x3<<21 | 0x1<<15 // bstrpick.w
    	case ABSTRPICKV:
    		return 0x3 << 22 // bstrpick.d
    	}
    
    	return 0
    }
    
    
    func (c *ctxt0) specailFpMovInst(a obj.As, fclass int, tclass int) uint32 {
    	switch a {
    	case AMOVV:
    		switch fclass {
    		case C_REG:
    			switch tclass {
    			case C_FREG:
    				return 0x452a << 10 // movgr2fr.d
    			case C_FCCREG:
    				return 0x4536 << 10 // movgr2cf
    			case C_FCSRREG:
    				return 0x4530 << 10 // movgr2fcsr
    			}
    		case C_FREG:
    			switch tclass {
    			case C_REG:
    				return 0x452e << 10 // movfr2gr.d
    			case C_FCCREG:
    				return 0x4534 << 10 // movfr2cf
    			}
    		case C_FCCREG:
    			switch tclass {
    			case C_REG:
    				return 0x4537 << 10 // movcf2gr
    			case C_FREG:
    				return 0x4535 << 10 // movcf2fr
    			}
    		case C_FCSRREG:
    			switch tclass {
    			case C_REG:
    				return 0x4532 << 10 // movfcsr2gr
    			}
    		}
    
    	case AMOVW:
    		switch fclass {
    		case C_REG:
    			switch tclass {
    			case C_FREG:
    				return 0x4529 << 10 // movgr2fr.w
    			}
    		case C_FREG:
    			switch tclass {
    			case C_REG:
    				return 0x452d << 10 // movfr2gr.s
    			}
    		}
    	}
    
    	c.ctxt.Diag("bad class combination: %s %s,%s\n", a, fclass, tclass)
    
    	return 0
    }
    
    
    func vshift(a obj.As) bool {
    	switch a {
    	case ASLLV,
    		ASRLV,