-
Notifications
You must be signed in to change notification settings - Fork 238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document branch relaxation #58
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -449,6 +449,36 @@ as seen by `objdump`: | |
14: 00028067 jr t0 # 0x10 | ||
``` | ||
|
||
Branches | ||
-------------------- | ||
|
||
Unconditional branches are implemented by the `j(al)?r?` pseudoinstructions. | ||
(The underlying instructions are `jalr?`.) | ||
The `j(al)?` targets can be any symbol or address. | ||
|
||
Conditional branches are implemented by the `b(l|g)(t|e)(z|u)?` and `b(eq|ne)z?` pseudoinstructions. | ||
(The underlying instructions are `b(lt|ge)u?` and `b(eq|ne)`.) | ||
Again, the targets can be any symbol or address. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Same as above.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, except there’s a 1 MiB limit. |
||
|
||
Various relaxations are performed when the target's offset from the branch exceeds the range of the underlying instruction's immediate field. | ||
|
||
For example, | ||
|
||
```assembly | ||
beqz t0, foo | ||
``` | ||
|
||
may be relaxed to a sequence of the form | ||
|
||
```assembly | ||
bnez t0, 1f | ||
j foo | ||
1: | ||
``` | ||
|
||
The `bnez` is further relaxed to `bne`, while `j` is relaxed to `jal` with a relocation. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are not relaxations. These are pure aliases for specific forms (bne with a zero register, and jal with a zero register). |
||
|
||
|
||
Floating-point rounding modes | ||
----------------------------- | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can it really be any symbol/address? I haven't tried them all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
“Any” is indeed an overstatement, since the call/tail macros have a maximum displacement of roughly 2 GB.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I'll read up on this and improve it.