Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Clang][TableGen] Add Features to TargetBuiltin #80279

Conversation

wangpc-pp
Copy link
Contributor

RISCV target will use this parameter, so we need a way to specify
it.

Created using spr 1.3.4
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Feb 1, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Feb 1, 2024

@llvm/pr-subscribers-clang

Author: Wang Pengcheng (wangpc-pp)

Changes

RISCV target will use this parameter, so we need a way to specify
it.


Full diff: https://github.com/llvm/llvm-project/pull/80279.diff

2 Files Affected:

  • (modified) clang/include/clang/Basic/BuiltinsBase.td (+3-1)
  • (modified) clang/utils/TableGen/ClangBuiltinsEmitter.cpp (+1-1)
diff --git a/clang/include/clang/Basic/BuiltinsBase.td b/clang/include/clang/Basic/BuiltinsBase.td
index b65b41be03265..bfccff5600ddb 100644
--- a/clang/include/clang/Basic/BuiltinsBase.td
+++ b/clang/include/clang/Basic/BuiltinsBase.td
@@ -87,7 +87,9 @@ class CustomEntry {
 }
 
 class AtomicBuiltin : Builtin;
-class TargetBuiltin : Builtin;
+class TargetBuiltin : Builtin {
+  string Features = "";
+}
 
 class LibBuiltin<string header, string languages = "ALL_LANGUAGES"> : Builtin {
   string Header = header;
diff --git a/clang/utils/TableGen/ClangBuiltinsEmitter.cpp b/clang/utils/TableGen/ClangBuiltinsEmitter.cpp
index dc10fa14c5959..48f55b8af97e4 100644
--- a/clang/utils/TableGen/ClangBuiltinsEmitter.cpp
+++ b/clang/utils/TableGen/ClangBuiltinsEmitter.cpp
@@ -219,7 +219,7 @@ void EmitBuiltinDef(llvm::raw_ostream &OS, StringRef Substitution,
     break;
   }
   case BuiltinType::TargetBuiltin:
-    OS << ", \"\"";
+    OS << ", \"" << Builtin->getValueAsString("Features") << "\"";
     break;
   case BuiltinType::AtomicBuiltin:
   case BuiltinType::Builtin:

@wangpc-pp
Copy link
Contributor Author

Ping.

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes seem reasonable to me but I'd feel more comfortable if the functionality was also being used (so that we'd get test coverage verifying its correctness). Do you think it would be reasonable to include the RISCV changes as well?

@wangpc-pp
Copy link
Contributor Author

wangpc-pp commented Feb 7, 2024

The changes seem reasonable to me but I'd feel more comfortable if the functionality was also being used (so that we'd get test coverage verifying its correctness). Do you think it would be reasonable to include the RISCV changes as well?

Yeah, I separated RISCV changes into another PR(#80280).

(I used SPR to do the stacked patches, but it seems that it won't refer to its parents or children)

@AaronBallman
Copy link
Collaborator

The changes seem reasonable to me but I'd feel more comfortable if the functionality was also being used (so that we'd get test coverage verifying its correctness). Do you think it would be reasonable to include the RISCV changes as well?

Yeah, I separated RISCV changes into another PR(#80280).

(I used SPR to do the stacked patches, but it seems that it won't refer to its parents or children)

Ah, yeah, I had no idea this was part of a stack of patches. :-( I think this is fine as-is now, thank you!

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wangpc-pp wangpc-pp merged commit eb9cd80 into main Feb 9, 2024
6 checks passed
@wangpc-pp wangpc-pp deleted the users/wangpc-pp/spr/clangtablegen-add-features-to-targetbuiltin branch February 9, 2024 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants