Class: YTLJit::TypedData

Inherits:
Object show all
Includes:
AbsArch
Defined in:
lib/ytljit/asmext.rb

Constant Summary

Constants included from AbsArch

AbsArch::AL, AbsArch::BL, AbsArch::CL, AbsArch::DL, AbsArch::FUNC_ARG, AbsArch::FUNC_ARG_YTL, AbsArch::FUNC_FLOAT_ARG, AbsArch::FUNC_FLOAT_ARG_YTL, AbsArch::INDIRECT_BPR, AbsArch::INDIRECT_RETR, AbsArch::INDIRECT_SPR, AbsArch::INDIRECT_TMPR, AbsArch::INDIRECT_TMPR2, AbsArch::INDIRECT_TMPR3

Constants included from SSE

SSE::XMM0, SSE::XMM1, SSE::XMM2, SSE::XMM3, SSE::XMM4, SSE::XMM5, SSE::XMM6, SSE::XMM7

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, ent) ⇒ TypedData

Returns a new instance of TypedData.



8
9
10
11
# File 'lib/ytljit/asmext.rb', line 8

def initialize(type, ent)
  @type = type
  @entity = ent
end

Instance Attribute Details

#entityObject (readonly)

Returns the value of attribute entity.



14
15
16
# File 'lib/ytljit/asmext.rb', line 14

def entity
  @entity
end

#typeObject (readonly)

Returns the value of attribute type.



13
14
15
# File 'lib/ytljit/asmext.rb', line 13

def type
  @type
end

Instance Method Details

#[](arg) ⇒ Object



16
17
18
# File 'lib/ytljit/asmext.rb', line 16

def [](arg)
  TypedData.new(@type[arg], @entity)
end

#gen_access(gen) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/ytljit/asmext.rb', line 20

def gen_access(gen)
  asm = gen.asm
  base = @entity
  case @type
  when AsmType::Scalar, AsmType::Pointer, AsmType::Array
    if @type == AsmType::DOUBLE then
      code = ""
      code += asm.update_state(gen.movsd(XMM0, base))
      [code, @type]
    else
      if base != TMPR then
        code = ""
        code += asm.update_state(gen.mov(TMPR, base))
        [code, @type]
      else
        ["", @type]
      end
    end

  when AsmType::StructMember
    code = ""

    oi = nil
    if base.is_a?(OpRegXMM) then
      oi = base
      
    elsif base != TMPR then
      code += asm.update_state(gen.call_stephandler)  if code != ""
      code += asm.update_state(gen.mov(TMPR, base))
      oi = OpIndirect.new(TMPR, @type.offset)

    else
      oi = OpIndirect.new(TMPR, @type.offset)
    end

    if @type.type == AsmType::DOUBLE then
      code += asm.update_state(gen.call_stephandler)  if code != ""
      code += asm.update_state(gen.movsd(XMM0, oi))

    elsif @type.type.is_a?(AsmType::Array) then
      code += asm.update_state(gen.call_stephandler) if code != ""
      code += asm.update_state(gen.lea(TMPR, oi))

    else
      code += asm.update_state(gen.call_stephandler)  if code != ""
      code += asm.update_state(gen.mov(TMPR, oi))

    end
    [code, @type.type]

  when AsmType::PointedData
    # Now support only index == 0

    code = ""
    if base != TMPR then
      code += asm.update_state(gen.mov(TMPR,  base))
    end
    if @type.offset != 0 then
      oi = OpIndirect.new(TMPR, @type.offset)
      code += asm.update_state(gen.call_stephandler)  if code != ""
      code += asm.update_state(gen.lea(TMPR, oi))
    end
    ineax = OpIndirect.new(TMPR)
    code += asm.update_state(gen.call_stephandler) if code != ""
    code += asm.update_state(gen.mov(TMPR,  ineax))
    [code, @type.type]
  end
end