Example #1
0
func checkLoad(instr *ssa.Load) error {
	op := ssa.GetOperands(instr)[0]

	ptr, ok := op.Type().(*types.Pointer)
	if !ok {
		return &InstrError{
			Instr:   instr,
			Message: "Expected pointer type, found `" + instr.Type().String() + "`",
		}
	}

	if !types.IsFirstClass(ptr.Element()) {
		return &InstrError{
			Instr:   instr,
			Message: "Pointer element type is not first class",
		}
	}

	return nil
}
Example #2
0
func (v Target) genLoad(a *allocator, instr *ssa.Load) {
	v.moveIntToReg(a, ssa.GetOperands(instr)[0], "r11")
	v.moveMemToMem("r11", "rbp", 0, -a.valOffset(instr), TypeStoreSizeInBits(instr.Type())/8)
}