[PATCH][X86] Add support for builtin 'rdpmc' to read performance monitoring counters.

Andrea Di Biagio andrea.dibiagio at gmail.com
Mon Jun 30 10:23:41 PDT 2014


Committed revision 212049.

Thanks for the review Nadav.


On Mon, Jun 30, 2014 at 5:59 PM, Nadav Rotem <nrotem at apple.com> wrote:
> I did not review the code carefully but it LGTM.
>
>> On Jun 30, 2014, at 9:00 AM, Andrea Di Biagio <andrea.dibiagio at gmail.com> wrote:
>>
>> ping.
>>
>>
>> On Mon, Jun 23, 2014 at 8:07 PM, Andrea Di Biagio
>> <andrea.dibiagio at gmail.com> wrote:
>>> Hi,
>>>
>>> This patch adds support for a new builtin instruction called
>>> '__builtin_ia32_rdpmc'.
>>> Builtin '__builtin_ia32_rdpmc' is defined as a "GCC builtin"; On X86,
>>> it can be used to read performance monitoring counters. It takes as
>>> input the index of the performance counter to read, and returns the
>>> value of the specified performance counter (a 64-bit quantity).
>>>
>>> Calls to this new builtin will map to instruction RDPMC.
>>> The index in input to the builtin call is moved to register %ECX. The
>>> result of the builtin call is the value of the specified performance
>>> counter (a 64-bit quantity - instruction RDPMC will return that
>>> quantity in registers RDX:RAX).
>>>
>>> This patch:
>>> 1) Adds builtin int_x86_rdpmc as a new GCCBuiltin;
>>> 2) Adds a new X86 DAG node called RDPMC_DAG;
>>> 3) Teaches how to lower this new builtin;
>>> 4) Adds an ISel pattern to instruction RDPMC;
>>> 5) Fixes the definition of instruction RDPMC adding %RAX and %RDX as
>>> implicit definitions, and adding %ECX as implicit-use;
>>> 6) Adds an LLVM test to verify that we correctly select the new intrinsic.
>>>
>>> A clang patch will follow that:
>>> - Adds a definition for the new x86 builtin '__builtin_ia32_rdpmc';
>>> - Adds an intrinsic function named '__rdpmc' to <ia32intrin.h>
>>>
>>> Please let me know if ok to commit.
>>>
>>> Thanks,
>>> Andrea Di Biagio.
>> <patch-x86-rdpmc.diff>
>



More information about the llvm-commits mailing list