本文整理汇总了Golang中github.com/TheJumpCloud/rsc/c2go/liblink.Prog类的典型用法代码示例。如果您正苦于以下问题:Golang Prog类的具体用法?Golang Prog怎么用?Golang Prog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Prog类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: follow
func follow(ctxt *liblink.Link, s *liblink.LSym) {
var firstp *liblink.Prog
var lastp *liblink.Prog
ctxt.Cursym = s
firstp = ctxt.Prg()
lastp = firstp
xfol(ctxt, s.Text, &lastp)
lastp.Link = nil
s.Text = firstp.Link
}
开发者ID:TheJumpCloud,项目名称:rsc,代码行数:10,代码来源:obj8.go
示例2: linkcase
func linkcase(casep *liblink.Prog) {
var p *liblink.Prog
for p = casep; p != nil; p = p.Link {
if p.As == ABCASE {
for ; p != nil && p.As == ABCASE; p = p.Link {
p.Pcrel = casep
}
break
}
}
}
开发者ID:TheJumpCloud,项目名称:rsc,代码行数:11,代码来源:obj5.go
示例3: load_g_cx
// Append code to p to load g into cx.
// Overwrites p with the first instruction (no first appendp).
// Overwriting p is unusual but it lets use this in both the
// prologue (caller must call appendp first) and in the epilogue.
// Returns last new instruction.
func load_g_cx(ctxt *liblink.Link, p *liblink.Prog) *liblink.Prog {
var next *liblink.Prog
p.As = AMOVL
p.From.Typ = D_INDIR + D_TLS
p.From.Offset = 0
p.To.Typ = D_CX
next = p.Link
progedit(ctxt, p)
for p.Link != next {
p = p.Link
}
if p.From.Index == D_TLS {
p.From.Scale = 2
}
return p
}
开发者ID:TheJumpCloud,项目名称:rsc,代码行数:21,代码来源:obj8.go
示例4: readprog
func readprog(b *bufio.Reader, p *liblink.Prog) {
if !undef[p] {
panic("double-def")
}
delete(undef, p)
p.Pc = rdint(b)
p.Lineno = int(rdint(b))
p.Link = rdprog(b)
p.As = int(rdint(b))
p.Reg = int(rdint(b))
p.Scond = int(rdint(b))
p.Width = int8(rdint(b))
readaddr(b, &p.From)
readaddr(b, &p.To)
}
开发者ID:TheJumpCloud,项目名称:rsc,代码行数:15,代码来源:main.go
示例5: Pconv
func Pconv(p *liblink.Prog) string {
var str string
var fp string
switch p.As {
case ADATA:
str = fmt.Sprintf("%.5d (%v)\t%v\t%v/%d,%v", p.Pc, p.Line(), Aconv(p.As), Dconv(p, 0, &p.From), p.From.Scale, Dconv(p, 0, &p.To))
case ATEXT:
if p.From.Scale != 0 {
str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%d,%v", p.Pc, p.Line(), Aconv(p.As), Dconv(p, 0, &p.From), p.From.Scale, Dconv(p, fmtLong, &p.To))
break
}
str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%v", p.Pc, p.Line(), Aconv(p.As), Dconv(p, 0, &p.From), Dconv(p, fmtLong, &p.To))
default:
str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%v", p.Pc, p.Line(), Aconv(p.As), Dconv(p, 0, &p.From), Dconv(p, 0, &p.To))
break
}
fp += str
return fp
}
开发者ID:TheJumpCloud,项目名称:rsc,代码行数:21,代码来源:list6.go
示例6: nopout
func nopout(p *liblink.Prog) {
p.As = ANOP
p.From.Typ = D_NONE
p.To.Typ = D_NONE
}
开发者ID:TheJumpCloud,项目名称:rsc,代码行数:5,代码来源:obj6.go
示例7: addstacksplit
func addstacksplit(ctxt *liblink.Link, cursym *liblink.LSym) {
var p *liblink.Prog
var q *liblink.Prog
var q1 *liblink.Prog
var autoffset int64
var deltasp int64
var a int
var pcsize int
var i uint32
var textstksiz int64
var textarg int64
if ctxt.Tlsg == nil {
ctxt.Tlsg = liblink.Linklookup(ctxt, "runtime.tlsg", 0)
}
if ctxt.Symmorestack[0] == nil {
if len(morename) > len(ctxt.Symmorestack) {
log.Fatalf("Link.symmorestack needs at least %d elements", len(morename))
}
for i = 0; i < uint32(len(morename)); i++ {
ctxt.Symmorestack[i] = liblink.Linklookup(ctxt, morename[i], 0)
}
}
if ctxt.Headtype == liblink.Hplan9 && ctxt.Plan9privates == nil {
ctxt.Plan9privates = liblink.Linklookup(ctxt, "_privates", 0)
}
ctxt.Cursym = cursym
if cursym.Text == nil || cursym.Text.Link == nil {
return
}
p = cursym.Text
parsetextconst(p.To.Offset, &textstksiz, &textarg)
autoffset = textstksiz
if autoffset < 0 {
autoffset = 0
}
cursym.Args = int(p.To.Offset >> 32)
cursym.Locals = textstksiz
if autoffset < liblink.StackSmall && p.From.Scale&liblink.NOSPLIT == 0 {
for q = p; q != nil; q = q.Link {
if q.As == ACALL {
goto noleaf
}
if (q.As == ADUFFCOPY || q.As == ADUFFZERO) && autoffset >= liblink.StackSmall-8 {
goto noleaf
}
}
p.From.Scale |= liblink.NOSPLIT
noleaf:
}
q = nil
if p.From.Scale&liblink.NOSPLIT == 0 || (p.From.Scale&liblink.WRAPPER != 0) {
p = liblink.Appendp(ctxt, p)
p = load_g_cx(ctxt, p) // load g into CX
}
if cursym.Text.From.Scale&liblink.NOSPLIT == 0 {
p = stacksplit(ctxt, p, autoffset, textarg, bool2int(cursym.Text.From.Scale&liblink.NEEDCTXT == 0), &q) // emit split check
}
if autoffset != 0 {
if autoffset%int64(ctxt.Arch.Regsize) != 0 {
ctxt.Diag("unaligned stack size %d", autoffset)
}
p = liblink.Appendp(ctxt, p)
p.As = AADJSP
p.From.Typ = D_CONST
p.From.Offset = autoffset
p.Spadj = autoffset
} else {
// zero-byte stack adjustment.
// Insert a fake non-zero adjustment so that stkcheck can
// recognize the end of the stack-splitting prolog.
p = liblink.Appendp(ctxt, p)
p.As = ANOP
p.Spadj = -ctxt.Arch.Ptrsize
p = liblink.Appendp(ctxt, p)
p.As = ANOP
p.Spadj = ctxt.Arch.Ptrsize
}
if q != nil {
q.Pcond = p
}
deltasp = autoffset
if cursym.Text.From.Scale&liblink.WRAPPER != 0 {
// g->panicwrap += autoffset + ctxt->arch->regsize;
p = liblink.Appendp(ctxt, p)
p.As = AADDL
p.From.Typ = D_CONST
p.From.Offset = autoffset + int64(ctxt.Arch.Regsize)
indir_cx(ctxt, &p.To)
p.To.Offset = 2 * ctxt.Arch.Ptrsize
}
if ctxt.Debugstack > 1 && autoffset != 0 {
// 6l -K -K means double-check for stack overflow
// even after calling morestack and even if the
// function is marked as nosplit.
p = liblink.Appendp(ctxt, p)
p.As = AMOVQ
indir_cx(ctxt, &p.From)
p.From.Offset = 0
p.To.Typ = D_BX
p = liblink.Appendp(ctxt, p)
//.........这里部分代码省略.........
开发者ID:TheJumpCloud,项目名称:rsc,代码行数:101,代码来源:obj6.go
示例8: progedit
func progedit(ctxt *liblink.Link, p *liblink.Prog) {
var literal string
var s *liblink.LSym
var q *liblink.Prog
// See obj6.c for discussion of TLS.
if canuselocaltls(ctxt) {
// Reduce TLS initial exec model to TLS local exec model.
// Sequences like
// MOVL TLS, BX
// ... off(BX)(TLS*1) ...
// become
// NOP
// ... off(TLS) ...
if p.As == AMOVL && p.From.Typ == D_TLS && D_AX <= p.To.Typ && p.To.Typ <= D_DI {
p.As = ANOP
p.From.Typ = D_NONE
p.To.Typ = D_NONE
}
if p.From.Index == D_TLS && D_INDIR+D_AX <= p.From.Typ && p.From.Typ <= D_INDIR+D_DI {
p.From.Typ = D_INDIR + D_TLS
p.From.Scale = 0
p.From.Index = D_NONE
}
if p.To.Index == D_TLS && D_INDIR+D_AX <= p.To.Typ && p.To.Typ <= D_INDIR+D_DI {
p.To.Typ = D_INDIR + D_TLS
p.To.Scale = 0
p.To.Index = D_NONE
}
} else {
// As a courtesy to the C compilers, rewrite TLS local exec load as TLS initial exec load.
// The instruction
// MOVL off(TLS), BX
// becomes the sequence
// MOVL TLS, BX
// MOVL off(BX)(TLS*1), BX
// This allows the C compilers to emit references to m and g using the direct off(TLS) form.
if p.As == AMOVL && p.From.Typ == D_INDIR+D_TLS && D_AX <= p.To.Typ && p.To.Typ <= D_DI {
q = liblink.Appendp(ctxt, p)
q.As = p.As
q.From = p.From
q.From.Typ = D_INDIR + p.To.Typ
q.From.Index = D_TLS
q.From.Scale = 2 // TODO: use 1
q.To = p.To
p.From.Typ = D_TLS
p.From.Index = D_NONE
p.From.Offset = 0
}
}
// TODO: Remove.
if ctxt.Headtype == liblink.Hplan9 {
if p.From.Scale == 1 && p.From.Index == D_TLS {
p.From.Scale = 2
}
if p.To.Scale == 1 && p.To.Index == D_TLS {
p.To.Scale = 2
}
}
// Rewrite CALL/JMP/RET to symbol as D_BRANCH.
switch p.As {
case ACALL,
AJMP,
ARET:
if (p.To.Typ == D_EXTERN || p.To.Typ == D_STATIC) && p.To.Sym != nil {
p.To.Typ = D_BRANCH
}
break
}
// Rewrite float constants to values stored in memory.
switch p.As {
case AFMOVF,
AFADDF,
AFSUBF,
AFSUBRF,
AFMULF,
AFDIVF,
AFDIVRF,
AFCOMF,
AFCOMFP,
AMOVSS,
AADDSS,
ASUBSS,
AMULSS,
ADIVSS,
ACOMISS,
AUCOMISS:
if p.From.Typ == D_FCONST {
var i32 uint32
var f32 float32
f32 = float32(p.From.U.Dval)
i32 = math.Float32bits(f32)
literal = fmt.Sprintf("$f32.%08x", uint32(i32))
s = liblink.Linklookup(ctxt, literal, 0)
if s.Typ == 0 {
s.Typ = liblink.SRODATA
liblink.Adduint32(ctxt, s, i32)
s.Reachable = 0
}
p.From.Typ = D_EXTERN
p.From.Sym = s
//.........这里部分代码省略.........
开发者ID:TheJumpCloud,项目名称:rsc,代码行数:101,代码来源:obj8.go
示例9: xfol
func xfol(ctxt *liblink.Link, p *liblink.Prog, last **liblink.Prog) {
var q *liblink.Prog
var i int
var a int
loop:
if p == nil {
return
}
if p.As == AJMP {
q = p.Pcond
if q != nil && q.As != ATEXT {
/* mark instruction as done and continue layout at target of jump */
p.Mark = 1
p = q
if p.Mark == 0 {
goto loop
}
}
}
if p.Mark != 0 {
/*
* p goes here, but already used it elsewhere.
* copy up to 4 instructions or else branch to other copy.
*/
i = 0
q = p
for ; i < 4; (func() { i++; q = q.Link })() {
if q == nil {
break
}
if q == *last {
break
}
a = q.As
if a == ANOP {
i--
continue
}
if nofollow(a) || pushpop(a) != 0 {
break // NOTE(rsc): arm does goto copy
}
if q.Pcond == nil || q.Pcond.Mark != 0 {
continue
}
if a == ACALL || a == ALOOP {
continue
}
for {
if p.As == ANOP {
p = p.Link
continue
}
q = liblink.Copyp(ctxt, p)
p = p.Link
q.Mark = 1
(*last).Link = q
*last = q
if q.As != a || q.Pcond == nil || q.Pcond.Mark != 0 {
continue
}
q.As = relinv(q.As)
p = q.Pcond
q.Pcond = q.Link
q.Link = p
xfol(ctxt, q.Link, last)
p = q.Link
if p.Mark != 0 {
return
}
goto loop /* */
}
}
q = ctxt.Prg()
q.As = AJMP
q.Lineno = p.Lineno
q.To.Typ = D_BRANCH
q.To.Offset = p.Pc
q.Pcond = p
p = q
}
/* emit p */
p.Mark = 1
(*last).Link = p
*last = p
a = p.As
/* continue loop with what comes after p */
if nofollow(a) {
return
}
if p.Pcond != nil && a != ACALL {
/*
* some kind of conditional branch.
* recurse to follow one path.
* continue loop on the other.
*/
q = liblink.Brchain(ctxt, p.Pcond)
if q != nil {
p.Pcond = q
}
q = liblink.Brchain(ctxt, p.Link)
//.........这里部分代码省略.........
开发者ID:TheJumpCloud,项目名称:rsc,代码行数:101,代码来源:obj8.go
示例10: addstacksplit
func addstacksplit(ctxt *liblink.Link, cursym *liblink.LSym) {
var p *liblink.Prog
var pl *liblink.Prog
var q *liblink.Prog
var q1 *liblink.Prog
var q2 *liblink.Prog
var o int
var autosize int64
var autoffset int64
autosize = 0
if ctxt.Symmorestack[0] == nil {
ctxt.Symmorestack[0] = liblink.Linklookup(ctxt, "runtime.morestack", 0)
ctxt.Symmorestack[1] = liblink.Linklookup(ctxt, "runtime.morestack_noctxt", 0)
}
q = nil
ctxt.Cursym = cursym
if cursym.Text == nil || cursym.Text.Link == nil {
return
}
softfloat(ctxt, cursym)
p = cursym.Text
autoffset = p.To.Offset
if autoffset < 0 {
autoffset = 0
}
cursym.Locals = autoffset
cursym.Args = p.To.Offset2
if ctxt.Debugzerostack != 0 {
if autoffset != 0 && p.Reg&liblink.NOSPLIT == 0 {
// MOVW $4(R13), R1
p = liblink.Appendp(ctxt, p)
p.As = AMOVW
p.From.Typ = D_CONST
p.From.Reg = 13
p.From.Offset = 4
p.To.Typ = D_REG
p.To.Reg = 1
// MOVW $n(R13), R2
p = liblink.Appendp(ctxt, p)
p.As = AMOVW
p.From.Typ = D_CONST
p.From.Reg = 13
p.From.Offset = 4 + autoffset
p.To.Typ = D_REG
p.To.Reg = 2
// MOVW $0, R3
p = liblink.Appendp(ctxt, p)
p.As = AMOVW
p.From.Typ = D_CONST
p.From.Offset = 0
p.To.Typ = D_REG
p.To.Reg = 3
// L:
// MOVW.nil R3, 0(R1) +4
// CMP R1, R2
// BNE L
pl = liblink.Appendp(ctxt, p)
p = pl
p.As = AMOVW
p.From.Typ = D_REG
p.From.Reg = 3
p.To.Typ = D_OREG
p.To.Reg = 1
p.To.Offset = 4
p.Scond |= C_PBIT
p = liblink.Appendp(ctxt, p)
p.As = ACMP
p.From.Typ = D_REG
p.From.Reg = 1
p.Reg = 2
p = liblink.Appendp(ctxt, p)
p.As = ABNE
p.To.Typ = D_BRANCH
p.Pcond = pl
}
}
/*
* find leaf subroutines
* strip NOPs
* expand RET
* expand BECOME pseudo
*/
for p = cursym.Text; p != nil; p = p.Link {
switch p.As {
case ACASE:
if ctxt.Flag_shared != 0 {
linkcase(p)
}
case ATEXT:
p.Mark |= LEAF
case ARET:
break
case ADIV,
ADIVU,
AMOD,
AMODU:
q = p
if ctxt.Sym_div == nil {
initdiv(ctxt)
}
//.........这里部分代码省略.........
开发者ID:TheJumpCloud,项目名称:rsc,代码行数:101,代码来源:obj5.go
示例11: stacksplit
func stacksplit(ctxt *liblink.Link, p *liblink.Prog, framesize int64, noctxt int) *liblink.Prog {
var arg int
// MOVW g_stackguard(g), R1
p = liblink.Appendp(ctxt, p)
p.As = AMOVW
p.From.Typ = D_OREG
p.From.Reg = REGG
p.To.Typ = D_REG
p.To.Reg = 1
if framesize <= liblink.StackSmall {
// small stack: SP < stackguard
// CMP stackguard, SP
p = liblink.Appendp(ctxt, p)
p.As = ACMP
p.From.Typ = D_REG
p.From.Reg = 1
p.Reg = REGSP
} else if framesize <= liblink.StackBig {
// large stack: SP-framesize < stackguard-StackSmall
// MOVW $-framesize(SP), R2
// CMP stackguard, R2
p = liblink.Appendp(ctxt, p)
p.As = AMOVW
p.From.Typ = D_CONST
p.From.Reg = REGSP
p.From.Offset = -framesize
p.To.Typ = D_REG
p.To.Reg = 2
p = liblink.Appendp(ctxt, p)
p.As = ACMP
p.From.Typ = D_REG
p.From.Reg = 1
p.Reg = 2
} else {
// Such a large stack we need to protect against wraparound
// if SP is close to zero.
// SP-stackguard+StackGuard < framesize + (StackGuard-StackSmall)
// The +StackGuard on both sides is required to keep the left side positive:
// SP is allowed to be slightly below stackguard. See stack.h.
// CMP $StackPreempt, R1
// MOVW.NE $StackGuard(SP), R2
// SUB.NE R1, R2
// MOVW.NE $(framesize+(StackGuard-StackSmall)), R3
// CMP.NE R3, R2
p = liblink.Appendp(ctxt, p)
p.As = ACMP
p.From.Typ = D_CONST
p.From.Offset = int64(uint32(liblink.StackPreempt & 0xFFFFFFFF))
p.Reg = 1
p = liblink.Appendp(ctxt, p)
p.As = AMOVW
p.From.Typ = D_CONST
p.From.Reg = REGSP
p.From.Offset = liblink.StackGuard
p.To.Typ = D_REG
p.To.Reg = 2
p.Scond = C_SCOND_NE
p = liblink.Appendp(ctxt, p)
p.As = ASUB
p.From.Typ = D_REG
p.From.Reg = 1
p.To.Typ = D_REG
p.To.Reg = 2
p.Scond = C_SCOND_NE
p = liblink.Appendp(ctxt, p)
p.As = AMOVW
p.From.Typ = D_CONST
p.From.Offset = framesize + (liblink.StackGuard - liblink.StackSmall)
p.To.Typ = D_REG
p.To.Reg = 3
p.Scond = C_SCOND_NE
p = liblink.Appendp(ctxt, p)
p.As = ACMP
p.From.Typ = D_REG
p.From.Reg = 3
p.Reg = 2
p.Scond = C_SCOND_NE
}
// MOVW.LS $framesize, R1
p = liblink.Appendp(ctxt, p)
p.As = AMOVW
p.Scond = C_SCOND_LS
p.From.Typ = D_CONST
p.From.Offset = framesize
p.To.Typ = D_REG
p.To.Reg = 1
// MOVW.LS $args, R2
p = liblink.Appendp(ctxt, p)
p.As = AMOVW
p.Scond = C_SCOND_LS
p.From.Typ = D_CONST
arg = ctxt.Cursym.Text.To.Offset2
if arg == 1 { // special marker for known 0
arg = 0
}
if arg&3 != 0 {
ctxt.Diag("misaligned argument size in stack split")
}
p.From.Offset = int64(arg)
p.To.Typ = D_REG
//.........这里部分代码省略.........
开发者ID:TheJumpCloud,项目名称:rsc,代码行数:101,代码来源:obj5.go
示例12: nocache_obj5
func nocache_obj5(p *liblink.Prog) {
p.Optab = 0
p.From.Class = 0
p.To.Class = 0
}
开发者ID:TheJumpCloud,项目名称:rsc,代码行数:5,代码来源:obj5.go
示例13: addstacksplit
func addstacksplit(ctxt *liblink.Link, cursym *liblink.LSym) {
var p *liblink.Prog
var q *liblink.Prog
var autoffset int64
var deltasp int64
var a int
if ctxt.Symmorestack[0] == nil {
ctxt.Symmorestack[0] = liblink.Linklookup(ctxt, "runtime.morestack", 0)
ctxt.Symmorestack[1] = liblink.Linklookup(ctxt, "runtime.morestack_noctxt", 0)
}
if ctxt.Headtype == liblink.Hplan9 && ctxt.Plan9privates == nil {
ctxt.Plan9privates = liblink.Linklookup(ctxt, "_privates", 0)
}
ctxt.Cursym = cursym
if cursym.Text == nil || cursym.Text.Link == nil {
return
}
p = cursym.Text
autoffset = p.To.Offset
if autoffset < 0 {
autoffset = 0
}
cursym.Locals = autoffset
cursym.Args = p.To.Offset2
q = nil
if p.From.Scale&liblink.NOSPLIT == 0 || (p.From.Scale&liblink.WRAPPER != 0) {
p = liblink.Appendp(ctxt, p)
p = load_g_cx(ctxt, p) // load g into CX
}
if cursym.Text.From.Scale&liblink.NOSPLIT == 0 {
p = stacksplit(ctxt, p, autoffset, bool2int(cursym.Text.From.Scale&liblink.NEEDCTXT == 0), &q) // emit split check
}
if autoffset != 0 {
p = liblink.Appendp(ctxt, p)
p.As = AADJSP
p.From.Typ = D_CONST
p.From.Offset = autoffset
p.Spadj = autoffset
} else {
// zero-byte stack adjustment.
// Insert a fake non-zero adjustment so that stkcheck can
// recognize the end of the stack-splitting prolog.
p = liblink.Appendp(ctxt, p)
p.As = ANOP
p.Spadj = -ctxt.Arch.Ptrsize
p = liblink.Appendp(ctxt, p)
p.As = ANOP
p.Spadj = ctxt.Arch.Ptrsize
}
if q != nil {
q.Pcond = p
}
deltasp = autoffset
if cursym.Text.From.Scale&liblink.WRAPPER != 0 {
// g->panicwrap += autoffset + ctxt->arch->ptrsize;
p = liblink.Appendp(ctxt, p)
p.As = AADDL
p.From.Typ = D_CONST
p.From.Offset = autoffset + ctxt.Arch.Ptrsize
p.To.Typ = D_INDIR + D_CX
p.To.Offset = 2 * ctxt.Arch.Ptrsize
}
if ctxt.Debugzerostack != 0 && autoffset != 0 && cursym.Text.From.Scale&liblink.NOSPLIT == 0 {
// 8l -Z means zero the stack frame on entry.
// This slows down function calls but can help avoid
// false positives in garbage collection.
p = liblink.Appendp(ctxt, p)
p.As = AMOVL
p.From.Typ = D_SP
p.To.Typ = D_DI
p = liblink.Appendp(ctxt, p)
p.As = AMOVL
p.From.Typ = D_CONST
p.From.Offset = autoffset / 4
p.To.Typ = D_CX
p = liblink.Appendp(ctxt, p)
p.As = AMOVL
p.From.Typ = D_CONST
p.From.Offset = 0
p.To.Typ = D_AX
p = liblink.Appendp(ctxt, p)
p.As = AREP
p = liblink.Appendp(ctxt, p)
p.As = ASTOSL
}
for ; p != nil; p = p.Link {
a = p.From.Typ
if a == D_AUTO {
p.From.Offset += deltasp
}
if a == D_PARAM {
p.From.Offset += deltasp + 4
}
a = p.To.Typ
if a == D_AUTO {
p.To.Offset += deltasp
}
if a == D_PARAM {
p.To.Offset += deltasp + 4
}
//.........这里部分代码省略.........
开发者ID:TheJumpCloud,项目名称:rsc,代码行数:101,代码来源:obj8.go
示例14: Pconv
func Pconv(p *liblink.Prog) string {
var str string
var sc string
var fp string
var a int
var s int
a = p.As
s = p.Scond
sc = extra[s&C_SCOND]
if s&C_SBIT != 0 {
sc += ".S"
}
if s&C_PBIT != 0 {
sc += ".P"
}
if s&C_WBIT != 0 {
sc += ".W"
}
if s&C_UBIT != 0 { /* ambiguous with FBIT */
sc += ".U"
}
if a == AMOVM {
if p.From.Typ == D_CONST {
str = fmt.Sprintf("%.5d (%v)\t%v%s\t%v,%v", p.Pc, p.Line(), Aconv(a), sc, RAconv(&p.From), Dconv(p, 0, &p.To))
} else if p.To.Typ == D_CONST {
str = fmt.Sprintf("%.5d (%v)\t%v%s\t%v,%v", p.Pc, p.Line(), Aconv(a), sc, Dconv(p, 0, &p.From), RAconv(&p.To))
} else {
str = fmt.Sprintf("%.5d (%v)\t%v%s\t%v,%v", p.Pc, p.Line(), Aconv(a), sc, Dconv(p, 0, &p.From), Dconv(p, 0, &p.To))
}
} else if a == ADATA {
str = fmt.Sprintf("%.5d (%v)\t%v\t%v/%d,%v", p.Pc, p.Line(), Aconv(a), Dconv(p, 0, &p.From), p.Reg, Dconv(p, 0, &p.To))
} else if p.As == ATEXT {
str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%d,%v", p.Pc, p.Line(), Aconv(a), Dconv(p, 0, &p.From), p.Reg, Dconv(p, 0, &p.To))
} else if p.Reg == NREG {
str = fmt.Sprintf("%.5d (%v)\t%v%s\t%v,%v", p.Pc, p.Line(), Aconv(a), sc, Dconv(p, 0, &p.From), Dconv(p, 0, &p.To))
} else if p.From.Typ != D_FREG {
str = fmt.Sprintf("%.5d (%v)\t%v%s\t%v,R%d,%v", p.Pc, p.Line(), Aconv(a), sc, Dconv(p, 0, &p.From), p.Reg, Dconv(p, 0, &p.To))
} else {
str = fmt.Sprintf("%.5d (%v)\t%v%s\t%v,F%d,%v", p.Pc, p.Line(), Aconv(a), sc, Dconv(p, 0, &p.From), p.Reg, Dconv(p, 0, &p.To))
}
fp += str
return fp
}
开发者ID:TheJumpCloud,项目名称:rsc,代码行数:45,代码来源:list5.go
示例15: xfol
func xfol(ctxt *liblink.Link, p *liblink.Prog, last **liblink.Prog) {
var q *liblink.Prog
var r *liblink.Prog
var a int
var i int
loop:
if p == nil {
return
}
a = p.As
if a == AB {
q = p.Pcond
if q != nil && q.As != ATEXT {
p.Mark |= FOLL
p = q
if p.Mark&FOLL == 0 {
goto loop
}
}
}
if p.Mark&FOLL != 0 {
i = 0
q = p
for ; i < 4; (func() { i++; q = q.Link })() {
if q == *last || q == nil {
break
}
a = q.As
if a == ANOP {
i--
continue
}
if a == AB || (a == ARET && q.Scond == C_SCOND_NONE) || a == ARFE || a == AUNDEF {
goto copy
}
if q.Pcond == nil || (q.Pcond.Mark&FOLL != 0) {
continue
}
if a != ABEQ && a != ABNE {
continue
}
copy:
for {
r = ctxt.Prg()
*r = *p
if r.Mark&FOLL == 0 {
fmt.Printf("can't happen 1\n")
}
r.Mark |= FOLL
if p != q {
p = p.Link
(*last).Link = r
*last = r
continue
}
(*last).Link = r
*last = r
if a == AB || (a == ARET && q.Scond == C_SCOND_NONE) || a == ARFE || a == AUNDEF {
return
}
r.As = ABNE
if a == ABNE {
r.As = ABEQ
}
r.Pcond = p.Link
r.Link = p.Pcond
if r.Link.Mark&FOLL == 0 {
xfol(ctxt, r.Link, last)
}
if r.Pcond.Mark&FOLL == 0 {
fmt.Printf("can't happen 2\n")
}
return
}
}
a = AB
q = ctxt.Prg()
q.As = a
q.Lineno = p.Lineno
q.To.Typ = D_BRANCH
q.To.Offset = p.Pc
q.Pcond = p
p = q
}
p.Mark |= FOLL
(*last).Link = p
*last = p
if a == AB || (a == ARET && p.Scond == C_SCOND_NONE) || a == ARFE || a == AUNDEF {
return
}
if p.Pcond != nil {
if a != ABL && a != ABX && p.Link != nil {
q = liblink.Brchain(ctxt, p.Link)
if a != ATEXT && a != ABCASE {
if q != nil && (q.Mark&FOLL != 0) {
p.As = relinv(a)
p.Link = p.Pcond
p.Pcond = q
}
}
//.........这里部分代码省略.........
开发者ID:TheJumpCloud,项目名称:rsc,代码行数:101,代码来源:obj5.go
示例16: progedit
func progedit(ctxt *liblink.Link, p *liblink.Prog) {
var literal string
var s *liblink.LSym
var tlsfallback *liblink.LSym
p.From.Class = 0
p.To.Class = 0
// Rewrite B/BL to symbol as D_BRANCH.
switch p.As {
case AB,
ABL,
ADUFFZERO,
ADUFFCOPY:
if p.To.Typ == D_OREG && (p.To.Name == D_EXTERN || p.To.Name == D_STATIC) && p.To.Sym != nil {
p.To.Typ = D_BRANCH
}
break
}
// Replace TLS register fetches on older ARM procesors.
switch p.As {
// If the instruction matches MRC 15, 0, <reg>, C13, C0, 3, replace it.
case AMRC:
if ctxt.Goarm < 7 && p.To.Offset&0xffff0fff == 0xee1d0f70 {
tlsfallback = liblink.Linklookup(ctxt, "runtime.read_tls_fallback", 0)
// BL runtime.read_tls_fallback(SB)
p.As = ABL
p.To.Typ = D_BRANCH
p.To.Sym = tlsfallback
p.To.Offset = 0
} else {
// Otherwise, MRC/MCR instructions need no further treatment.
p.As = AWORD
}
break
}
// Rewrite float constants to values stored in memory.
switch p.As {
case AMOVF:
if p.From.Typ == D_FCONST && chipfloat5(ctxt, p.From.U.Dval) < 0 && (chipzero5(ctxt, p.From.U.Dval) < 0 || p.Scond&C_SCOND != C_SCOND_NONE) {
var i32 uint32
var f32 float32
f32 = float32(p.From.U.Dval)
i32 = math.Float32bits(f32)
literal = fmt.Sprintf("$f32.%08x", i32)
s = liblink.Linklookup(ctxt, literal, 0)
if s.Typ == 0 {
s.Typ = liblink.SRODATA
liblink.Adduint32(ctxt, s, i32)
s.Reachable = 0
}
p.From.Typ = D_OREG
p.From.Sym = s
p.From.Name = D_EXTERN
p.From.Offset = 0
}
case AMOVD:
if p.From.Typ == D_FCONST && chipfloat5(ctxt, p.From.U.Dval) < 0 && (chipzero5(ctxt, p.From.U.Dval) < 0 || p.Scond&C_SCOND != C_SCOND_NONE) {
var i64 uint64
i64 = math.Float64bits(p.From.U.Dval)
literal = fmt.Sprintf("$f64.%016x", uint64(i64))
s = liblink.Linklookup(ctxt, literal, 0)
if s.Typ == 0 {
s.Typ = liblink.SRODATA
liblink.Adduint64(ctxt, s, i64)
s.Reachable = 0
}
p.From.Typ = D_OREG
p.From.Sym = s
p.From.Name = D_EXTERN
p.From.Offset = 0
}
break
}
if ctxt.Flag_shared != 0 {
// Shared libraries use R_ARM_TLS_IE32 instead of
// R_ARM_TLS_LE32, replacing the link time constant TLS offset in
// runtime.tlsg with an address to a GOT entry containing the
// offset. Rewrite $runtime.tlsg(SB) to runtime.tlsg(SB) to
// compensate.
if ctxt.Tlsg == nil {
ctxt.Tlsg = liblink.Linklookup(ctxt, "runtime.tlsg", 0)
}
if p.From.Typ == D_CONST && p.From.Name == D_EXTERN && p.From.Sym == ctxt.Tlsg {
p.From.Typ = D_OREG
}
if p.To.Typ == D_CONST && p.To.Name == D_EXTERN && p.To.Sym == ctxt.Tlsg {
p.To.Typ = D_OREG
}
}
}
开发者ID:TheJumpCloud,项目名称:rsc,代码行数:89,代码来源:obj5.go
示例17: settextflag
func settextflag(p *liblink.Prog, f int) {
p.Reg = f
}
开发者ID:TheJumpCloud,项目名称:rsc,代码行数:3,代码来源:obj5.go
示例18: progedit
func progedit(ctxt *liblink.Link, p *liblink.Prog) {
var literal string
var s *liblink.LSym
var q *liblink.Prog
// Thread-local storage references use the TLS pseudo-register.
// As a register, TLS refers to the thread-local storage base, and it
// can only be loaded into another register:
//
// MOVQ TLS, AX
//
// An offset from the thread-local storage base is written off(reg)(TLS*1).
// Semantically it is off(reg), but the (TLS*1) annotation marks this as
// indexing from the loaded TLS base. This emits a relocation so that
// if the linker needs to adjust the offset, it can. For example:
//
// MOVQ TLS, AX
// MOVQ 8(AX)(TLS*1), CX // load m into CX
//
// On systems that support direct access to the TLS memory, this
// pair of instructions can be reduced to a direct TLS memory reference:
//
// MOVQ 8(TLS), CX // load m into CX
//
// The 2-instruction and 1-instruction forms correspond roughly to
// ELF TLS initial exec mode and ELF TLS local exec mode, respectively.
//
// We applies this rewrite on systems that support the 1-instruction form.
// The decision is made using only the operating system (and probably
// the -shared flag, eventually), not the link mode. If some link modes
// on a particular operating system require the 2-instruction form,
// then all builds for that operating system will use the 2-instruction
// form, so that the link mode decision can be delayed to link time.
//
// In this way, all supported systems use identical instructions to
// access TLS, and they are rewritten appropriately first here in
// liblink and then finally using relocations in the linker.
if canuselocaltls(ctxt) {
// Reduce TLS initial exec model to TLS local exec model.
// Sequences like
// MOVQ TLS, BX
// ... off(BX)(TLS*1) ...
// become
// NOP
// ... off(TLS) ...
//
// TODO(rsc): Remove the Hsolaris special case. It exists only to
// guarantee we are producing byte-identical binaries as before this code.
// But it should be unnecessary.
if (p.As == AMOVQ || p.As == AMOVL) && p.From.Typ == D_TLS && D_AX <= p.To.Typ && p.To.Typ <= D_R15 && ctxt.Headtype != liblink.Hsolaris {
nopout(p)
}
if p.From.Index == D_TLS && D_INDIR+D_AX <= p.From.Typ && p.From.Typ <= D_INDIR+D_R15 {
p.From.Typ = D_INDIR + D_TLS
p.From.Scale = 0
p.From.Index = D_NONE
}
if p.To.Index == D_TLS && D_INDIR+D_AX <= p.To.Typ && p.To.Typ <= D_INDIR+D_R15 {
p.To.Typ = D_INDIR + D_TLS
p.To.Scale = 0
p.To.Index = D_NONE
}
} else {
// As a courtesy to the C compilers, rewrite TLS local exec load as TLS initial exec load.
// The instruction
// MOVQ off(TLS), BX
// becomes the sequence
// MOVQ TLS, BX
// MOVQ off(BX)(TLS*1), BX
// This allows the C compilers to emit references to m and g using the direct off(TLS) form.
if (p.As == AMOVQ || p.As == AMOVL) && p.From.Typ == D_INDIR+D_TLS && D_AX <= p.To.Typ && p.To.Typ <= D_R15 {
q = liblink.Appendp(ctxt, p)
q.As = p.As
q.From = p.From
q.From.Typ = D_INDIR + p.To.Typ
q.From.Index = D_TLS
q.From.Scale = 2 // TODO: use 1
q.To = p.To
p.From.Typ = D_TLS
p.From.Index = D_NONE
p.From.Offset = 0
}
}
// TODO: Remove.
if ctxt.Headtype == liblink.Hwindows || ctxt.Headtype == liblink.Hplan9 {
if p.From.Scale == 1 && p.From.Index == D_TLS {
p.From.Scale = 2
}
if p.To.Scale == 1 && p.To.Index == D_TLS {
p.To.Scale = 2
}
}
if ctxt.Headtype == liblink.Hnacl {
nacladdr(ctxt, p, &p.From)
nacladdr(ctxt, p, &p.To)
}
// Maintain information about code generation mode.
if ctxt.Mode == 0 {
ctxt.Mode = 64
}
p.Mode = ctxt.Mode
//.........这里部分代码省略.........
开发者ID:TheJumpCloud,项目名称:rsc,代码行数:101,代码来源:obj6.go
示例19: stacksplit
// Append code to p to check for stack split.
// Appends to (does not overwrite) p.
// Assumes g is in CX.
// Returns last new instruction.
// On return, *jmpok is the instruction that should jump
// to the stack frame allocation if no split is needed.
func stacksplit(ctxt *liblink.Link, p *liblink.Prog, framesize int64, noctxt int, jmpok **liblink.Prog) *liblink.Prog {
var q *liblink.Prog
var q1 *liblink.Prog
var arg int
if ctxt.Debugstack != 0 {
// 8l -K means check not only for stack
// overflow but stack underflow.
// On underflow, INT 3 (breakpoint).
// Underflow itself is rare but this also
// catches out-of-sync stack guard info.
p = liblink.Appendp(ctxt, p)
p.As = ACMPL
p.From.Typ = D_INDIR + D_CX
p.From.Offset = 4
p.To.Typ = D_SP
p = liblink.Appendp(ctxt, p)
p.As = AJCC
p.To.Typ = D_BRANCH
p.To.Offset = 4
q1 = p
p = liblink.Appendp(ctxt, p)
p.As = AINT
p.From.Typ = D_CONST
p.From.Offset = 3
p = liblink.Appendp(ctxt, p)
p.As = ANOP
q1.Pcond = p
}
q1 = nil
if framesize <= liblink.StackSmall {
// small stack: SP <= stackguard
// CMPL SP, stackguard
p = liblink.Appendp(ctxt, p)
p.As = ACMPL
p.From.Typ = D_SP
p.To.Typ = D_INDIR + D_CX
} else if framesize <= liblink.StackBig {
// large stack: SP-framesize <= stackguard-StackSmall
// LEAL -(framesize-StackSmall)(SP), AX
// CMPL AX, stackguard
p = liblink.Appendp(ctxt, p)
p.As = ALEAL
p.From.Typ = D_INDIR + D_SP
p.From.Offset = -(framesize - liblink.StackSmall)
p.To.Typ = D_AX
p = liblink.Appendp(ctxt, p)
p.As = ACMPL
p.From.Typ = D_AX
p.To.Typ = D_INDIR + D_CX
} else {
// Such a large stack we need to protect against wraparound
// if SP is close to zero.
// SP-stackguard+StackGuard <= framesize + (StackGuard-StackSmall)
// The +StackGuard on both sides is required to keep the left side positive:
// SP is allowed to be slightly below stackguard. See stack.h.
//
// Preemption sets stackguard to StackPreempt, a very large value.
// That breaks the math above, so we have to check for that explicitly.
// MOVL stackguard, CX
// CMPL CX, $StackPreempt
// JEQ label-of-call-to-morestack
// LEAL StackGuard(SP), AX
// SUBL stackguard, AX
// CMPL AX, $(framesize+(StackGuard-StackSmall))
p = liblink.Appendp(ctxt, p)
p.As = AMOVL
p.From.Typ = D_INDIR + D_CX
p.From.Offset = 0
p.To.Typ = D_SI
p = liblink.Appendp(ctxt, p)
p.As = ACMPL
p.From.Typ = D_SI
p.To.Typ = D_CONST
p.To.Offset = int64(uint32(liblink.StackPreempt & 0xFFFFFFFF))
p = liblink.Appendp(ctxt, p)
p.As = AJEQ
p.To.Typ = D_BRANCH
q1 = p
p = liblink.Appendp(ctxt, p)
p.As = ALEAL
p.From.Typ = D_INDIR + D_SP
p.From.Offset = liblink.StackGuard
p.To.Typ = D_AX
p = liblink.Appendp(ctxt, p)
p.As = ASUBL
p.From.Typ = D_SI
p.From.Offset = 0
p.To.Typ = D_AX
p = liblink.Appendp(ctxt, p)
p.As = ACMPL
p.From.Typ = D_AX
p.To.Typ = D_CONST
p.To.Offset = framesize + (liblink.StackGuard - liblink.StackSmall)
}
//.........这里部分代码省略.........
开发者ID:TheJumpCloud,项目名称:rsc,代码行数:101,代码来源:obj8.go
示例20: softfloat
func softfloat(ctxt *liblink.Link, cursym *liblink.LSym) {
var p *liblink.Prog
var next *liblink.Prog
var symsfloat *liblink.LSym
var wasfloat int
if ctxt.Goarm > 5 {
return
}
symsfloat = liblink.Linklookup(ctxt, "_sfloat", 0)
wasfloat = 0
for p = cursym.Text; p != nil; p = p.Link {
if p.Pcond != nil {
p.Pcond.Mark |= LABEL
}
}
for p = cursym.Text; p != nil; p = p.Link {
switch p.As {
case AMOVW:
if p.To.Typ == D_FREG || p.From.Typ == D_FREG {
goto soft
}
goto notsoft
case AMOVWD,
AMOVWF,
AMOVDW,
AMOVFW,
AMOVFD,
AMOVDF,
AMOVF,
AMOVD,
ACMPF,
ACMPD,
AADDF,
AADDD,
ASUBF,
ASUBD,
AMULF,
AMULD,
ADIVF,
ADIVD,
ASQRTF,
ASQRTD,
AABSF,
AABSD:
goto soft
default:
goto notsoft
}
soft:
if wasfloat == 0 || (p.Mark&LABEL != 0) {
next = ctxt.Prg()
*next = *p
// BL _sfloat(SB)
*p = zprg_obj5
p.Ctxt = ctxt
p.Link = next
p.As = ABL
p.To.Typ = D_BRANCH
p.To.Sym = symsfloat
p.Lineno = next.Lineno
p = next
wasfloat = 1
}
continue
notsoft:
wasfloat = 0
}
}
开发者ID:TheJumpCloud,项目名称:rsc,代码行数:68,代码来源:obj5.go
注:本文中的github.com/TheJumpCloud/rsc/c2go/liblink.Prog类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论