Rewrite inbounds_gep with a loop
This commit is contained in:
parent
090cde9811
commit
908304e257
@ -876,17 +876,13 @@ fn gep(&mut self, _typ: Type<'gcc>, ptr: RValue<'gcc>, indices: &[RValue<'gcc>])
|
|||||||
|
|
||||||
fn inbounds_gep(&mut self, _typ: Type<'gcc>, ptr: RValue<'gcc>, indices: &[RValue<'gcc>]) -> RValue<'gcc> {
|
fn inbounds_gep(&mut self, _typ: Type<'gcc>, ptr: RValue<'gcc>, indices: &[RValue<'gcc>]) -> RValue<'gcc> {
|
||||||
// NOTE: array indexing is always considered in bounds in GCC (TODO(antoyo): to be verified).
|
// NOTE: array indexing is always considered in bounds in GCC (TODO(antoyo): to be verified).
|
||||||
// TODO: replace with a loop like gep.
|
let mut indices = indices.into_iter();
|
||||||
match indices.len() {
|
let index = indices.next().expect("first index in inbounds_gep");
|
||||||
1 => {
|
let mut result = self.context.new_array_access(None, ptr, *index);
|
||||||
self.context.new_array_access(None, ptr, indices[0]).get_address(None)
|
for index in indices {
|
||||||
},
|
result = self.context.new_array_access(None, result, *index);
|
||||||
2 => {
|
|
||||||
let array = ptr.dereference(None); // TODO(antoyo): assert that first index is 0?
|
|
||||||
self.context.new_array_access(None, array, indices[1]).get_address(None)
|
|
||||||
},
|
|
||||||
_ => unimplemented!(),
|
|
||||||
}
|
}
|
||||||
|
result.get_address(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn struct_gep(&mut self, value_type: Type<'gcc>, ptr: RValue<'gcc>, idx: u64) -> RValue<'gcc> {
|
fn struct_gep(&mut self, value_type: Type<'gcc>, ptr: RValue<'gcc>, idx: u64) -> RValue<'gcc> {
|
||||||
|
Loading…
Reference in New Issue
Block a user