"
Copyright (c) 2012-2016 Igor Stasenko
Martin McClure
Damien Pollet
Camillo Bruni
Guido Chari
2016-now Jan Vrany <jan.vrany [at] fit . cvut . cz>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"
"{ 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:'documentation'!
copyright
"
Copyright (c) 2012-2016 Igor Stasenko
Martin McClure
Damien Pollet
Camillo Bruni
Guido Chari
2016-now Jan Vrany <jan.vrany [at] fit . cvut . cz>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"
! !
!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
! !