Fixed AsmJit tests.
"{ Package: 'jv:dragonfly/asm' }"
"{ NameSpace: Smalltalk }"
AJOperand subclass:#AJBaseReg
instanceVariableNames:'size code name'
classVariableNames:''
poolDictionaries:'AJConstants'
category:'AsmJit-Operands'
!
AJBaseReg comment:'AJBaseReg -- abstract superclass of all register operands.
Instance Variables:
size <Number> Width in bytes (1, 2, 4, 8...)
code <Integer> Non-negative integer, encoding varies with subclass. For AJx86GPRegisters, ten bits: xyttttnnnn
where nnnn is the register number 0-15, tttt is the "type", which encodes size as a power of 2.
Higher types are used in other subclasses.
If y is 1, REX prefix is required to encode this register.
If x is 1, this register cannot be used when any REX prefix is present in the instruction.
name <Symbol> Name by which this register may be referenced in instructions'
!
!AJBaseReg class methodsFor:'instance creation'!
code: aRegisterCode name: aSymbol
^ self basicNew initializeWithCode: aRegisterCode name: aSymbol
! !
!AJBaseReg methodsFor:'accessing'!
annotation: anObject
"registers gereally are used as single instances, hence putting
an annotation on the default register will change the annotation
for all the users. To avoid that, the receiver is copied first"
^ self copy
basicAnnotation: anObject;
yourself
!
code
"Answer the value of code"
^ code
!
code: anObject
"Set the value of code"
code := anObject
!
description
^ String streamContents: [ :s | self descriptionOn: s ].
!
index
^ code bitAnd: RegCodeMask
!
influencingRegisters
^ #()
!
name
^ name
!
size
^ size
!
type
^ code bitAnd: RegTypeMask
! !
!AJBaseReg methodsFor:'comparing'!
= otherReg
^ (self class == otherReg class) and: [ code = otherReg code ]
!
hash
^ code hash
! !
!AJBaseReg methodsFor:'initialize-release'!
initializeWithCode: aRegisterCode name: aSymbol
super initialize.
self code: aRegisterCode. "Also sets size"
name := aSymbol
! !
!AJBaseReg methodsFor:'printing'!
descriptionOn: aStream
self subclassResponsibility
! !
!AJBaseReg methodsFor:'private'!
basicAnnotation: anObject
"private setter"
annotation := anObject
! !
!AJBaseReg methodsFor:'testing'!
isGeneralPurpose
self subclassResponsibility
!
isUpperBank
"Used for emitting the REX Prefix Byte on 64bit machines"
^ self index > 7
!
isX86
self subclassResponsibility
!
prohibitsRex
"Answer true if this register cannot be used in any instruction that has a REX prefix.
Of the general-purpose registers, this is true only of SPL, BPL, SIL, DIL."
^ (code & RegProhibitsRexMask) ~~ 0
"Modified (format): / 15-12-2015 / 23:30:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
requiresRex
"Answer true if use of this register requires that the instruction have a REX prefix.
This can be because the register cannot be accessed except with REX (high bank or 64-only low byte)
or because the register is 64-bits wide"
^(code & RegRequiresRexMask) ~~ 0
! !