pub fn emit_addr_sym(backend: &mut CodeGenerator, dest: &P<Value>, src: &P<Value>, vm: &VM) {
    match src.v {
        Value_::Memory(ref mem) => {
            match mem {
                &MemoryLocation::Symbolic {
                    ref label,
                    is_global,
                    is_native
                } => {
                    if is_global {
                        // Set dest to be the page address of the entry for src in the GOT
                        backend.emit_adrp(&dest, &src);

                        // Note: The offset should always be a valid immediate offset
                        // as it is 12-bits
                        // (The same size as an immediate offset)
                        let offset = P(Value {
                            hdr: MuEntityHeader::unnamed(vm.next_id()),
                            ty: UINT64_TYPE.clone(),
                            v: Value_::Constant(Constant::ExternSym(if is_native {
                                Arc::new(format!("/*C*/:got_lo12:{}", label))
                            } else {
                                Arc::new(format!(":got_lo12:{}", mangle_name(label.clone())))
                            }))
                        });

                        // [dest + low 12 bits of the GOT entry for src]
                        let address_loc = P(Value {
                            hdr: MuEntityHeader::unnamed(vm.next_id()),
                            ty: ADDRESS_TYPE.clone(),
                            // should be ptr<src.ty>
                            v: Value_::Memory(MemoryLocation::Address {
                                base: dest.clone(),
                                offset: Some(offset),
                                shift: 0,
                                signed: false
                            })
                        });

                        // Load dest with the value in the GOT entry for src
                        backend.emit_ldr(&dest, &address_loc, false);
                    } else {
                        // Load 'dest' with the value of PC + the PC-offset of src
                        backend.emit_adr(&dest, &src);
                    }
                }
                _ => panic!("Expected symbolic memory location")
            }
        }
        _ => panic!("Expected memory value")
    }
}
// Sets 'dest' to the absolute address of the given global symbolic memory location
//WARNING: this assumes that the resulting assembly file is compiled with -fPIC
Sets 'dest' to the absolute address of the given global symbolic memory location
WARNING: this assumes that the resulting assembly file is compiled with -fPIC
Sets ' dest ' to the absolute address of the given global symbolic memory location WARNING : this assumes that the resulting assembly file is compiled with - fPIC
pub fn emit_addr_sym(backend: &mut CodeGenerator, dest: &P<Value>, src: &P<Value>, vm: &VM) {
    match src.v {
        Value_::Memory(ref mem) => {
            match mem {
                &MemoryLocation::Symbolic {
                    ref label,
                    is_global,
                    is_native
                } => {
                    if is_global {
                        // Set dest to be the page address of the entry for src in the GOT
                        backend.emit_adrp(&dest, &src);
                        // Note: The offset should always be a valid immediate offset
                        // as it is 12-bits
                        // (The same size as an immediate offset)
                        let offset = P(Value {
                            hdr: MuEntityHeader::unnamed(vm.next_id()),
                            ty: UINT64_TYPE.clone(),
                            v: Value_::Constant(Constant::ExternSym(if is_native {
                                Arc::new(format!("/*C*/:got_lo12:{}", label))
                            } else {
                                Arc::new(format!(":got_lo12:{}", mangle_name(label.clone())))
                            }))
                        });
                        // [dest + low 12 bits of the GOT entry for src]
                        let address_loc = P(Value {
                            hdr: MuEntityHeader::unnamed(vm.next_id()),
                            ty: ADDRESS_TYPE.clone(),
                            // should be ptr<src.ty>
                            v: Value_::Memory(MemoryLocation::Address {
                                base: dest.clone(),
                                offset: Some(offset),
                                shift: 0,
                                signed: false
                            })
                        });
                        // Load dest with the value in the GOT entry for src
                        backend.emit_ldr(&dest, &address_loc, false);
                    } else {
                        // Load 'dest' with the value of PC + the PC-offset of src
                        backend.emit_adr(&dest, &src);
                    }
                }
                _ => panic!("Expected symbolic memory location")
            }
        }
        _ => panic!("Expected memory value")
    }
}
pub fn emit_addr_sym ( backend : & mut CodeGenerator , dest : & P < Value > , src : & P < Value > , vm : & VM ) { match src . v { Value_ :: Memory ( ref mem ) => { match mem { & MemoryLocation :: Symbolic { ref label , is_global , is_native } => { if is_global { // Set dest to be the page address of the entry for src in the GOT backend . emit_adrp ( & dest , & src ) ; // Note: The offset should always be a valid immediate offset // as it is 12-bits // (The same size as an immediate offset) let offset = P ( Value { hdr : MuEntityHeader :: unnamed ( vm . next_id ( ) ) , ty : UINT64_TYPE . clone ( ) , v : Value_ :: Constant ( Constant :: ExternSym ( if is_native { Arc :: new ( format ! ( " " label ) ) } else { Arc :: new ( format ! ( " " mangle_name ( label clone ( ) ) ) ) } ) ) } ) ; // [dest + low 12 bits of the GOT entry for src] let address_loc = P ( Value { hdr : MuEntityHeader :: unnamed ( vm . next_id ( ) ) , ty : ADDRESS_TYPE . clone ( ) , // should be ptr<src.ty> v : Value_ :: Memory ( MemoryLocation :: Address { base : dest . clone ( ) , offset : Some ( offset ) , shift : 0 , signed : false } ) } ) ; // Load dest with the value in the GOT entry for src backend . emit_ldr ( & dest , & address_loc , false ) ; } else { // Load 'dest' with the value of PC + the PC-offset of src backend . emit_adr ( & dest , & src ) ; } } _ => panic ! ( " " ) } } _ => panic ! ( " " ) } }
Sets 'dest' to the absolute address of the given global symbolic memory location
WARNING: this assumes that the resulting assembly file is compiled with -fPIC
Sets ' dest ' to the absolute address of the given global symbolic memory location WARNING : this assumes that the resulting assembly file is compiled with - fPIC
backend
&mut CodeGenerator
dest
&P<Value>
src
&P<Value>
vm
&VM
backend
&mut CodeGenerator
dest
&P<Value>
src
&P<Value>
vm
&VM