This is an archive of the discontinued LLVM Phabricator instance.

[libc][hdr-gen] Add a new 'begin' and `end command to control headers
AbandonedPublic

Authored by jhuber6 on Jun 26 2023, 11:33 AM.

Details

Summary

This patch adds a %%begin() and %%end() command to allow the
headergen binary to create custom wrappers and preamples around the
standard header. This does nothing in this patch and is purely NFC. A
future patch will use this to implement GPU wrapper headers as in
https://discourse.llvm.org/t/rfc-implementing-gpu-headers-in-the-llvm-c-library/71523.

Diff Detail

Event Timeline

jhuber6 created this revision.Jun 26 2023, 11:33 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJun 26 2023, 11:33 AM
jhuber6 requested review of this revision.Jun 26 2023, 11:33 AM
jhuber6 planned changes to this revision.Jun 27 2023, 5:33 AM

I'm realizing that a better but more invasive solution would be to have something like the following:

%%begin()
#include <__llvm_libc_common.h>
%%end()

%%public_api()

After trying to base my offloading support off of this I realized that several headers have non-trivial constructions, so what I really need is a hook to wrap around these and insert some GPU headers at the start. So it would look more like

#include <llvm-libc-macros/gpu-macros.h>

#ifdef __OFFLOADING
#include_next <stdheader.h>
#else
#include <__llvm_libc_common.h>
#endif

#ifndef __OFFLOADING
extern SomeType;
#endif

void some_entrypoint.
jhuber6 retitled this revision from [libc][hdr-gen] Add a new 'include_header' command to control headers to [libc][hdr-gen] Add a new 'begin' and `end command to control headers.Jun 27 2023, 9:22 AM
jhuber6 edited the summary of this revision. (Show Details)
jhuber6 updated this revision to Diff 535018.Jun 27 2023, 9:22 AM

Changing approach

I think we should nail down the design before we start making changes. More specifically, what are the begin and end commands going to do?

libc/utils/HdrGen/BeginCommand.cpp
25

nit: should be begin

jhuber6 updated this revision to Diff 535046.Jun 27 2023, 10:24 AM

Fixing nit.

I'm going to upload a follow-up patch very soon. I simply wanted to separate all the line noise of updating the headers from that patch.

jhuber6 abandoned this revision.Jul 14 2023, 3:59 PM