Class: Crabstone::ARM64::Operand

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/arch/arm64.rb

Instance Method Summary collapse

Instance Method Details

#barrier?Boolean

Returns:

  • (Boolean)


125
126
127
# File 'lib/arch/arm64.rb', line 125

def barrier?
    self[:type] == OP_BARRIER
end

#cimm?Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/arch/arm64.rb', line 101

def cimm?
    self[:type] == OP_CIMM
end

#ext?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/arch/arm64.rb', line 89

def ext?
    self[:ext] != EXT_INVALID
end

#fp?Boolean

Returns:

  • (Boolean)


109
110
111
# File 'lib/arch/arm64.rb', line 109

def fp?
    self[:type] == OP_FP
end

#imm?Boolean

Returns:

  • (Boolean)


97
98
99
# File 'lib/arch/arm64.rb', line 97

def imm?
    self[:type] == OP_IMM
end

#mem?Boolean

Returns:

  • (Boolean)


105
106
107
# File 'lib/arch/arm64.rb', line 105

def mem?
    self[:type] == OP_MEM
end

#mrs?Boolean

Returns:

  • (Boolean)


121
122
123
# File 'lib/arch/arm64.rb', line 121

def mrs?
    self[:type] == OP_REG_MRS
end

#msr?Boolean

Returns:

  • (Boolean)


117
118
119
# File 'lib/arch/arm64.rb', line 117

def msr?
    self[:type] == OP_REG_MSR
end

#prefetch?Boolean

Returns:

  • (Boolean)


129
130
131
# File 'lib/arch/arm64.rb', line 129

def prefetch?
    self[:type] == OP_PREFETCH
end

#pstate?Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/arch/arm64.rb', line 113

def pstate?
    self[:type] == OP_PSTATE
end

#reg?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/arch/arm64.rb', line 93

def reg?
    self[:type] == OP_REG
end

#shift?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/arch/arm64.rb', line 85

def shift?
    self[:shift][:type] != SFT_INVALID
end

#shift_typeObject



77
78
79
# File 'lib/arch/arm64.rb', line 77

def shift_type
    self[:shift][:type]
end

#shift_valueObject



81
82
83
# File 'lib/arch/arm64.rb', line 81

def shift_value
    self[:shift][:value]
end

#valid?Boolean

Returns:

  • (Boolean)


133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/arch/arm64.rb', line 133

def valid?
    [
        OP_INVALID,
        OP_REG,
        OP_CIMM,
        OP_IMM,
        OP_FP,
        OP_MEM,
        OP_REG_MRS,
        OP_REG_MSR,
        OP_PSTATE,
        OP_SYS,
        OP_PREFETCH,
        OP_BARRIER
    ].include? self[:type]
end

#valueObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/arch/arm64.rb', line 54

def value
    case self[:type]
    when *[OP_REG, OP_REG_MRS, OP_REG_MSR]  # Register operand.
        self[:value][:reg]
    when *[OP_IMM, OP_CIMM]                 # Immediate operand.
        self[:value][:imm]
    when OP_FP                              # Floating-Point immediate operand.
        self[:value][:fp]
    when OP_MEM                             # Memory operand
        self[:value][:mem]
    when OP_PSTATE                          # PState operand.
        self[:value][:pstate]
    when OP_SYS                             # SYS operand for IC/DC/AT/TLBI instructions.
        self[:value][:sys]
    when OP_PREFETCH                        # Prefetch operand (PRFM).
        self[:value][:prefetch]
    when OP_BARRIER                         # Memory barrier operand (ISB/DMB/DSB instructions).
        self[:value][:barrier]
    else
        nil
    end
end