示例#1
0
文件: irgen.go 项目: mewmew/uc
// emitJmp emits to b an unconditional branch terminator to the target basic
// block.
func (b *BasicBlock) emitJmp(target value.NamedValue) {
	term, err := instruction.NewJmp(target)
	if err != nil {
		panic(fmt.Sprintf("unable to create unconditional br instruction; %v", err))
	}
	b.SetTerm(term)
}
示例#2
0
文件: irx.go 项目: llir/llvm
// NewJmpInst returns a new unconditional branch instruction based on the given
// target branch.
func NewJmpInst(ltarget interface{}) (*instruction.Jmp, error) {
	target, ok := ltarget.(*LocalDummy)
	if !ok {
		return nil, errutil.Newf("invalid target type; expected *LocalDummy, got %T", ltarget)
	}
	return instruction.NewJmp(target)
}
示例#3
0
文件: fix.go 项目: llir/llvm
// fixTerm replaces dummy values within the given terminator with their
// corresponding local variables.
func (m dummyMap) fixTerm(oldTerm instruction.Terminator) instruction.Terminator {
	switch oldTerm := oldTerm.(type) {
	case *instruction.Ret:
		oldVal := oldTerm.Value()
		var val value.Value
		if oldVal != nil {
			val = m.fixValue(oldVal)
		}
		term, err := instruction.NewRet(val)
		if err != nil {
			panic(errutil.Err(err))
		}
		return term
	case *instruction.Jmp:
		target := m.fixNamedValue(oldTerm.Target())
		term, err := instruction.NewJmp(target)
		if err != nil {
			panic(errutil.Err(err))
		}
		return term
	case *instruction.Br:
		cond := m.fixValue(oldTerm.Cond())
		trueBranch := m.fixNamedValue(oldTerm.TrueBranch())
		falseBranch := m.fixNamedValue(oldTerm.FalseBranch())
		term, err := instruction.NewBr(cond, trueBranch, falseBranch)
		if err != nil {
			panic(errutil.Err(err))
		}
		return term
	case *instruction.Switch:
		panic("irx.dummyMap.fixTerm: Switch not yet implemented")
	case *instruction.IndirectBr:
		panic("irx.dummyMap.fixTerm: IndirectBr not yet implemented")
	case *instruction.Invoke:
		panic("irx.dummyMap.fixTerm: Invoke not yet implemented")
	case *instruction.Resume:
		panic("irx.dummyMap.fixTerm: Resume not yet implemented")
	case *instruction.CatchSwitch:
		panic("irx.dummyMap.fixTerm: CatchSwitch not yet implemented")
	case *instruction.CatchRet:
		panic("irx.dummyMap.fixTerm: CatchRet not yet implemented")
	case *instruction.CleanupRet:
		panic("irx.dummyMap.fixTerm: CleanupRet not yet implemented")
	case *instruction.Unreachable:
		panic("irx.dummyMap.fixTerm: Unreachable not yet implemented")
	default:
		panic(fmt.Sprintf("support for terminator type %T not yet implemented", oldTerm))
	}
}