-
Notifications
You must be signed in to change notification settings - Fork 352
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
cleanup overflow binop code #28
Merged
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
58b4fac
implement overflowing ops
oli-obk 3ba4f6d
remove code repetition and fix overflowing intrinsics
oli-obk 6376ef4
run the *compiled* run-pass tests on the host machine
oli-obk 4f48bef
cfail test for std::env::args()
oli-obk e3a2bf8
clippy
oli-obk 00eb198
implement fn -> unsafe fn pointer casts
oli-obk 874d683
improve method names and add documentation
oli-obk d977642
compiletest 2.0 uses json errors and doesn't depend on the output for…
oli-obk e90ee16
fix comparing of function pointers
oli-obk a1082b9
Merge remote-tracking branch 'origin/master' into oflo
oli-obk ed4af21
fix master
oli-obk b9ac85d
rustc does overflow checking for us, don't duplicate it.
oli-obk 68469be
rename function cache member
oli-obk 0821a15
no need for EvalContext::eval_binop
oli-obk 3e3aeab
implement bit masks as the compiler would translate them
oli-obk a088f10
add a comment explaining the magic numbers
oli-obk 001ae69
remove the bad rhs value error and panic instead. the typechecker pre…
oli-obk c7039db
simplify the masked rhs computation
oli-obk 65de5dd
simplify even more
oli-obk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,17 +82,19 @@ pub fn binary_op<'tcx>(bin_op: mir::BinOp, left: PrimVal, right: PrimVal) -> Eva | |
U64(_) => 6, | ||
_ => unreachable!(), | ||
}; | ||
let mask = (1 << mask_bits) - 1; | ||
let r = match right { | ||
I8(i) => (i & ((1 << mask_bits) - 1)) as u32, | ||
I16(i) => (i & ((1 << mask_bits) - 1)) as u32, | ||
I32(i) => (i & ((1 << mask_bits) - 1)) as u32, | ||
I64(i) => (i & ((1 << mask_bits) - 1)) as u32, | ||
U8(i) => (i & ((1 << mask_bits) - 1)) as u32, | ||
U16(i) => (i & ((1 << mask_bits) - 1)) as u32, | ||
U32(i) => (i & ((1 << mask_bits) - 1)) as u32, | ||
U64(i) => (i & ((1 << mask_bits) - 1)) as u32, | ||
I8(i) => i as u8 & mask, | ||
I16(i) => i as u8 & mask, | ||
I32(i) => i as u8 & mask, | ||
I64(i) => i as u8 & mask, | ||
U8(i) => i as u8 & mask, | ||
U16(i) => i as u8 & mask, | ||
U32(i) => i as u8 & mask, | ||
U64(i) => i as u8 & mask, | ||
_ => panic!("bad MIR: bitshift rhs is not integral"), | ||
}; | ||
let r = r as u32; | ||
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. This isn't necessary, is it? 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. Also, |
||
macro_rules! shift { | ||
($v:ident, $l:ident, $r:ident) => ({ | ||
match bin_op { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@solson Do you have things set up so you can use
bug!
andspan_bug!
fromlibrustc
? I think those would be preferred.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.
That should be possible. I filed #32.