[LLVMdev] 答复: 答复: [LLVMdev] How to bind a register variable with a given general purpose register?
ether
etherzhhb at gmail.com
Mon Jan 4 05:37:31 PST 2010
or you can just add a built-in function in c frontend "readadcreg()" and
emit it as llvm.zhu.readadcreg(), so you can just call the built-in
function to get the adc register value.
On 2010-1-4 21:27, Demon(Xiangyang) Zhu 朱向阳 wrote:
> Hi Ether,
>
> Thank you very much. I will try it soon as your description.
>
> Regards
>
> ________________________________________
> 发件人: ether [etherzhhb at gmail.com]
> 发送时间: 2010年1月4日 3:29
> 收件人: Demon(Xiangyang) Zhu 朱向阳
> 抄送: llvmdev at cs.uiuc.edu
> 主题: Re: 答复: [LLVMdev] How to bind a register variable with a given general purpose register?
>
> hi zhu,
>
> i am not sure if your c frontend support "int ADC asm("GPR13");"
> i think you could:
>
> 1. add a attribute "GPR13"(or a more meaningful name like "adcreg") and
> the corresponding handler, so you code "int ADC asm("GPR13");" became
> "int ADC __attribute__((GPR13));"
> 2. add a intrinsic functions like "llvm.zhu.readadcreg()".
> 3. map any read to the variable marked with __attribute__((GPR13)) to
> llvm.zhu.readadcreg() instead of "load" instruction
> 4. assign gpr13 to a special register class like "gpr13class" instead of
> gprclass, so gpr13 will not be allocated as other gpr.
> 5. lower instrinisic functions "llvm.zhu.readadcreg()" to register node
> "gpr13" in your backend.
>
> regards
>
> --ether
>
> On 2010-1-4 18:01, Demon(Xiangyang) Zhu 朱向阳 wrote:
>
>> Hi Ether,
>>
>> The hardware had been fixed now.
>> If map it to memory space, it will cost another instruction cycle to execute 'a = ADCREG',
>> Algorithm accesses the A/D convert very frequently. To get higher precision at lower frequency
>> A/D output is connected to R13 directly. For the moment algorithm code is something like
>> assemble and difficult to maintain. I want to setup a c environment for it, but i don't know
>> how to bind a register variable with a given general purpose register.
>>
>> Thanks!
>>
>> ________________________________________
>> 发件人: llvmdev-bounces at cs.uiuc.edu [llvmdev-bounces at cs.uiuc.edu] 代表 ether [etherzhhb at gmail.com]
>> 发送时间: 2010年1月4日 0:36
>> 收件人: llvmdev at cs.uiuc.edu
>> 主题: Re: [LLVMdev] How to bind a register variable with a given general purpose register?
>>
>> hi zhu,
>>
>> i think you should map the peripheral registers to data memory space
>> instead of register file, then mark that memory address as "volatile".
>> like said the adc register was mapped to address 0xc0000, and then the
>> corresponding c source will goes like this:
>> //define the register
>> #define ADCREG (*((volatile unsigned int *)0xc0000))
>> //read the register
>> a = ADCREG
>>
>> --ether
>>
>> On 2010-1-4 10:59, Heyu Zhu wrote:
>>
>>
>>> Hi everyone,
>>> There are 16 GPRs in my RISC, but in fact GPR13 is read-only and
>>> connected to output of an A/D converter.
>>> It would be very convenient if i could bind a register variable with
>>> GPR13.
>>> Because i am a newbie i don't know how my llvm backend can support that.
>>> I plan to implement it as below.
>>> A. first declare a global variable in c-code
>>> int ADC asm("GPR13");
>>> B. If backend finds a variable is loaded from "GPR13" use GPR13 instead.
>>> C. backend can't allocate GPR13 to other variable
>>> Is it a foolish method? Is there a better one? Please give me some
>>> guidance
>>> Thanks
>>>
>>>
>>> _______________________________________________
>>> LLVM Developers mailing list
>>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>>
>>>
>>>
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list