本文整理汇总了Golang中github.com/tsavola/wag/internal/gen.RegCoder.MinMemorySize方法的典型用法代码示例。如果您正苦于以下问题:Golang RegCoder.MinMemorySize方法的具体用法?Golang RegCoder.MinMemorySize怎么用?Golang RegCoder.MinMemorySize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tsavola/wag/internal/gen.RegCoder
的用法示例。
在下文中一共展示了RegCoder.MinMemorySize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: StoreOp
// StoreOp makes sure that index gets zero-extended if it's a VarReg operand.
func (mach X86) StoreOp(code gen.RegCoder, oper uint16, index, x values.Operand, offset uint32) {
size := oper >> 8
baseReg, indexReg, ownIndexReg, disp := mach.opMemoryAddress(code, size, index, offset)
if ownIndexReg {
defer code.FreeReg(types.I64, indexReg)
}
store := memoryStores[uint8(oper)]
insnType := store.insnType
if insnType == 0 {
insnType = x.Type
}
if x.Storage == values.Imm {
value := x.ImmValue()
value32 := int32(value)
switch {
case size == 1:
value32 = int32(int8(value32))
case size == 2:
value32 = int32(int16(value32))
case size == 4 || (value >= -0x80000000 && value < 0x80000000):
default:
goto large
}
store.insn.opImmToIndirect(code, insnType, 0, indexReg, baseReg, disp, value32)
return
large:
}
valueReg, _, own := mach.opBorrowMaybeResultReg(code, x, false)
if own {
defer code.FreeReg(x.Type, valueReg)
}
store.insn.opToIndirect(code, insnType, valueReg, 0, indexReg, baseReg, disp)
}
// opMemoryAddress may return the scratch register as the base.
func (mach X86) opMemoryAddress(code gen.RegCoder, size uint16, index values.Operand, offset uint32) (baseReg, indexReg regs.R, ownIndexReg bool, disp int32) {
sizeReach := uint64(size - 1)
reachOffset := uint64(offset) + sizeReach
if reachOffset >= 0x80000000 {
code.OpTrapCall(traps.MemoryOutOfBounds)
return
}
alreadyChecked := reachOffset < uint64(index.Bounds.Upper)
switch index.Storage {
case values.Imm:
value := uint64(index.ImmValue())
if value >= 0x80000000 {
code.OpTrapCall(traps.MemoryOutOfBounds)
return
}
addr := value + uint64(offset)
reachAddr := addr + sizeReach
if reachAddr >= 0x80000000 {
code.OpTrapCall(traps.MemoryOutOfBounds)
return
}
if reachAddr < uint64(code.MinMemorySize()) || alreadyChecked {
baseReg = regMemoryBase
indexReg = NoIndex
disp = int32(addr)
return
}
Lea.opFromIndirect(code, types.I64, regScratch, 0, NoIndex, regMemoryBase, int32(reachAddr))
default:
reg, zeroExt, own := mach.opBorrowMaybeScratchReg(code, index, true)
if !zeroExt {
Mov.opFromReg(code, types.I32, reg, reg) // zero-extend index
}
if alreadyChecked {
baseReg = regMemoryBase
indexReg = reg
ownIndexReg = own
disp = int32(offset)
return
}
//.........这里部分代码省略.........