Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 40182 invoked from network); 2 Feb 2007 14:40:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Feb 2007 14:40:57 -0000 Received: (qmail 15985 invoked by uid 500); 2 Feb 2007 14:41:00 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 15957 invoked by uid 500); 2 Feb 2007 14:41:00 -0000 Mailing-List: contact dev-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list dev@harmony.apache.org Received: (qmail 15948 invoked by uid 99); 2 Feb 2007 14:41:00 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Feb 2007 06:41:00 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of mike.fursov@gmail.com designates 209.85.132.240 as permitted sender) Received: from [209.85.132.240] (HELO an-out-0708.google.com) (209.85.132.240) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Feb 2007 06:40:51 -0800 Received: by an-out-0708.google.com with SMTP id b2so543248ana for ; Fri, 02 Feb 2007 06:40:30 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=bhl6+KKbRwEHdiay8M+dJy9fgzPRQ6aRSBvkVCoTkCeLOLRPQO9wS44gVIjQpbAAH34LAyHgM6GjxKctwe2WZrr7o9/DauZouxpMXkMpFCx/68nfMxbxXlAJc2skUwt4n0rvqidSe9hBJY9TuLZjtoPIriiELxWbNTBkf15yIXA= Received: by 10.115.33.1 with SMTP id l1mr291168waj.1170426629165; Fri, 02 Feb 2007 06:30:29 -0800 (PST) Received: by 10.114.130.4 with HTTP; Fri, 2 Feb 2007 06:30:29 -0800 (PST) Message-ID: Date: Fri, 2 Feb 2007 20:30:29 +0600 From: "Mikhail Fursov" To: dev@harmony.apache.org Subject: Re: [Drlvm][Opt]Some Questions about LIR expressions In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_7819_8474863.1170426629130" References: <6342af3e0701272307r161cb1eaj7650f5ecc49700b@mail.gmail.com> <6342af3e0701301746u256c4fe3hc7e4e4c92b40f727@mail.gmail.com> <6342af3e0701310210n231c65b7kc0db727ad3c969a8@mail.gmail.com> <6342af3e0702010152x51e39ec9naac6e5d06378e687@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_7819_8474863.1170426629130 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline + some more details: > Opnd* baseOpnd = irManager.newImmOpnd(typeManager.getUnmanagedPtrType( > typeManager.getUIntPtrType()), (POINTER_SIZE_INT)&g_Address); > Opnd* memOpnd = irManager.newMemOpnd(typeManager.getUIntPtrType > (),MemOpndKind_Heap,baseOpnd,NULL, NULL, NULL); These 2 above are equivalent to the followin C code: [pseudo-code] Address memOpnd = (Address)&g_Address; // here, the &g_Address presumed to be the global static var Now, if you want to write to this, then [pseudo-code] *(int*)memOpnd = 0xFFFFFF; Is this what you're trying to achieve? If yes, then in LIR this is Inst* inst = irManager.newCopyPseudoInst(Mnemonic_MOV, memOpnd, your0xFFFF); On 2/2/07, Mikhail Fursov wrote: > > Zouqiong, > LIR is very lowlevel representation and you are allowed to use only x86 > commands. See "Pentium4. Instruction reference set" for instructions details > every time you are not sure in results. > > The problem is that you can't encode mov [mem], [mem] in a single > instruction and have to use 2 instructions and intermediate value here. > Did I understand your problem right? > > On 2/1/07, zouqiong wrote: > > > > 2007/2/1, Mikhail Fursov : > > > > > > Hi Zouqiong, > > > here are answers: > > > > > > On 1/31/07, zouqiong < ustczz@gmail.com> wrote: > > > > > > > > Sorry, I still have two questions. > > > > 1. > > > > > > > > What is the difference between newOpnd, newImmOpnd and newMemOpnd? > > > > > > > > > Here is an extraction from sources that describes the difference: > > > Opnd * IRManager::newImmOpnd(Type * type, int64 immediate) > > > { > > > Opnd * opnd = newOpnd(type); > > > opnd->assignImmValue(immediate); > > > return opnd; > > > } > > > > > > Opnd * IRManager::newMemOpnd(Type * type, MemOpndKind k, Opnd * base, > > Opnd > > > * > > > index, Opnd * scale, Opnd * displacement, RegName segReg) > > > { > > > Opnd * opnd = newOpnd(type); > > > opnd->assignMemLocation(k,base,index,scale,displacement); > > > if (segReg != RegName_Null) > > > opnd->setSegReg(segReg); > > > return opnd; > > > } > > > > > > > > > So newImmOpnd and newMemOpnd are simple wrappers for newOpnd > > > > > > > > > > > > Opnd* baseOpnd= irManager.newImmOpnd(typeManager.getUnmanagedPtrType( > > > > typeManager.getUIntPtrType()), > > > > (POINTER_SIZE_INT)¤t_obj_acc_record_pointer); > > > > Opnd* RefOpnd = irManager.newMemOpnd(typeManager.getUIntPtrType(), > > > > MemOpndKind_Heap, > > > > baseOpnd_current_obj_acc_record_pointer, NULL, NULL, NULL); > > > > appendInsts( irManager.newCopyPseudoInst(Mnemonic_MOV, RefOpnd, > > > > (Opnd*)elemBase)); > > > > > > > > > > > > Opnd* memOpnd = irManager.newMemOpnd(typeManager.getUIntPtrType(), > > > > MemOpndKind_Heap, > > > > baseOpnd_current_obj_acc_record_pointer, NULL, NULL, NULL); > > > > appendInsts(irManager.newInst(Mnemonic_SUB,memOpnd, > > irManager.newImmOpnd > > > ( > > > > typeManager.getUInt32Type(), 16))); > > > > > > > > > > > > What's the difference between memOpnd and baseOpnd? > > > > > > > > > Mem-opnd contains up to 4 opnds: base,index,scale,and displacement. So > > > mem-opnd is used to support complex address form in LIR. > > > > > > > > > I look the code emitted as below, It seems that they have no > > difference. > > > > > > > > mov 0xb40534, %esi > > > > mov %ebp, (%esi) > > > > > > > > mov 0xb40534, %ebp > > > > subl 0x10, 0x0(%ebp) > > > > > > > > 2. If I want to generate such code: > > > > mov 0xb400534, %esi > > > > mov (%esi), %esi > > > > > > > > How should I write the LIR? > > > > > > > > > If you want to preserve register, use newRegOpnd with the register > > name. > > > It > > > will add additional constraint to opnd. > > > If you want save value by address, create new mem-opnd with a base > > opnd > > > contains address and use newCopyPseudoInst to put new value to the > > address > > > represented by mem-opnd. > > > > > > > > > Feel free to ask more if you have questions.. > > > -- > > > Mikhail Fursov > > > > > Thanks, Mikhail, you are very very very kind! :-) > > > > I want to use value load from some address to index the memory. > > > > Opnd* baseOpnd = irManager.newImmOpnd(typeManager.getUnmanagedPtrType( > > typeManager.getUIntPtrType ()), (POINTER_SIZE_INT)&Address); > > Opnd* memOpnd = irManager.newMemOpnd(typeManager.getUIntPtrType > > (),MemOpndKind_Heap,baseOpnd,NULL, NULL, NULL); > > > > memOpnd means Address, right? > > > > I want to write to the memory pointed by Address. But I can't use the > > memOpnd as a base opnd of a mem opnd. > > > > In fact > > > > Opnd* RefOpnd = > > irManager.newMemOpnd(typeManager.getUIntPtrType(),MemOpndKind_Heap, > > memOpnd, NULL, NULL, NULL); > > > > will cause error. > > > > I don't know whether I have expressed myself rightly. > > > > Thanks > > Qiong > > > > -- > > Best Regards, > > Qiong,Zou > > > > > > -- > Mikhail Fursov -- Mikhail Fursov ------=_Part_7819_8474863.1170426629130--