Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
  • This project
    • Loading...
  • Sign in / Register
S
swiftshader
  • Project
    • Overview
    • Details
    • Activity
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 0
    • Issues 0
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Chen Yisong
  • swiftshader
  • Repository

Switch branch/tag
  • swiftshader
  • third_party
  • subzero
  • src
  • IceTargetLoweringX86BaseImpl.h
Find file
BlameHistoryPermalink
  • Nicolas Capens's avatar
    Fix lowering and optimization of 64-bit absolute addresses · bc1a66c7
    Nicolas Capens authored Feb 05, 2021
    x86-64 does not support 64-bit immediates as absolute memory addresses.
    They have to be stored in a register, which can then be used as [base].
    
    Previously we addressed this at the SubzeroReactor level by emitting a
    Bitcast from an Ice::Operand to an Ice::Variable, for which Subzero
    already supported 64-bit constants as input.
    
    This change implements X86OperandMem creation from a 64-bit constant
    operand by letting legalize() move it into a GPR and using it as the
    memory operand's base register.
    
    A Reactor unit test is added to exercise this.
    
    Another issue was that doLoadOpt() assumed all load instructions are
    candidates for fusing into a subsequent instruction which takes the
    result of the load. This isn't true when for 64-bit constant addresses
    an instruction to copy it into a register is inserted.
    
    For now this case is simply skipped. A future optimization could adjust
    the iterators properly so the load from [base] can be fused with the
    next instruction.
    
    Lastly, it is possible for a 64-bit constant to fit within a 32-bit
    immediate, in which case legalize() by default does not perform the copy
    into a GPR (note this is to allow moves and calls with 64-bit
    immediates, where they are legal), and simply returns the 64-bit
    constant. So we must not allow legalization to an immediate in this
    case. Note that while we could replace it with a 32-bit constant, it's
    rare for absolute addresses to fit in this range, and it would be
    non-deterministic which path is taken, so for consistency we don't
    perform this optimization.
    
    Bug: b/148272103
    Change-Id: I5fcfa971dc93f2307202ee11619e84c65fe46188
    Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/52768Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
    Presubmit-Ready: Nicolas Capens <nicolascapens@google.com>
    Reviewed-by: 's avatarAntonio Maiorano <amaiorano@google.com>
    bc1a66c7
IceTargetLoweringX86BaseImpl.h 297 KB
EditWeb IDE
×

Replace IceTargetLoweringX86BaseImpl.h

Attach a file by drag & drop or click to upload


Cancel
A new branch will be created in your fork and a new merge request will be started.