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

WIP: Support C11 atomics required by dav1d #814

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
C11 atomics: Add tag, move information over to Rust side
  • Loading branch information
chrysn authored and thedataking committed Feb 6, 2023
commit 21988b2568159b9f9645ba8408c30dd9ffde3422
22 changes: 13 additions & 9 deletions c2rust-ast-exporter/src/AstExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ class TypeEncoder final : public TypeVisitor<TypeEncoder> {

void VisitVariableArrayType(const VariableArrayType *T);

void VisitAtomicType(const AtomicType *AT);

void VisitIncompleteArrayType(const IncompleteArrayType *T) {
auto t = T->getElementType();
auto qt = encodeQualType(t);
Expand Down Expand Up @@ -2472,15 +2474,17 @@ void TypeEncoder::VisitVariableArrayType(const VariableArrayType *T) {

VisitQualType(t);
}
//
//void TypeEncoder::VisitAtomicType(const AtomicType *AT) {
// std::string msg =
// "C11 Atomic types are not supported. Aborting.";
//// auto horse = AT->get
//// astEncoder->printError(msg, AT);
// AT->getValueType()->dump();
// abort();
//}

void TypeEncoder::VisitAtomicType(const AtomicType *AT) {
auto t = AT->getValueType();
auto qt = encodeQualType(t);

encodeType(AT, TagAtomicType, [qt](CborEncoder *local) {
cbor_encode_uint(local, qt);
});

VisitQualType(t);
}

class TranslateConsumer : public clang::ASTConsumer {
Outputs *outputs;
Expand Down
2 changes: 2 additions & 0 deletions c2rust-ast-exporter/src/ast_tags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ enum TypeTag {
TagComplexType,
TagHalf,
TagBFloat16,

TagAtomicType,
};

enum StringTypeTag {
Expand Down
5 changes: 5 additions & 0 deletions c2rust-transpile/src/c_ast/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,11 @@ impl ConversionContext {
self.processed_nodes.insert(new_id, OTHER_TYPE);
}

TypeTag::TagAtomicType => {
// Next step in atomics implementation: Transfer to a CTypeKind
panic!("C11 Atomics are not implemented in C2Rust yet.");
}

t => panic!(
"Type conversion not implemented for {:?} expecting {:?}",
t, expected_ty
Expand Down