Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -2892,16 +2892,16 @@ def CHERILibCall : DeclOrTypeAttr {
let Subjects = SubjectList<[Function], ErrorDiag>;
}

def CHERIOTMMIODevice : DeclOrTypeAttr {
def CHERIoTMMIODevice : DeclOrTypeAttr {
let Spellings = [GNU<"cheriot_mmio">];
let Documentation = [CHERIOTMMIODeviceDocs];
let Documentation = [CHERIoTMMIODeviceDocs];
let Args = [StringArgument<"DeviceName">, StringArgument<"EncodedPermissions", 1>];
let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
}

def CHERIOTSharedObject : DeclOrTypeAttr {
def CHERIoTSharedObject : DeclOrTypeAttr {
let Spellings = [GNU<"cheriot_shared_object">];
let Documentation = [CHERIOTSharedObjectDocs];
let Documentation = [CHERIoTSharedObjectDocs];
let Args = [StringArgument<"ObjectName">, StringArgument<"EncodedPermissions", 1>];
let Subjects = SubjectList<[GlobalVar], ErrorDiag>;
}
Expand Down
18 changes: 10 additions & 8 deletions clang/include/clang/Basic/AttrDocs.td
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,7 @@ Further reading for other annotations:
}];
}

def CHERIOTMMIODeviceDocs : Documentation {
def CHERIoTMMIODeviceDocs : Documentation {
let Category = DocCatVariable;
let Content = [{
Indicates that the global it refers to must be treated as a cross-compartment
Expand All @@ -1486,7 +1486,7 @@ qualifiers.
of the MMIO-bound device. An example of this is ``"uart"``. The
``"<permissions_encoding>"`` indicates the permissions of the capability
resulting from the import. The permissions encoding is a string of variable
length. The symbols allowed in the string are ``R``, ``W``, ``c`` and ``m``,
length. The symbols allowed in the string are ``R``, ``W``, ``c``, ``m`` and ``g``,
whose meaning is explained in the table below.


Expand All @@ -1496,18 +1496,19 @@ whose meaning is explained in the table below.
"``R``","Load (Read)", "May be used to read.",""
"``W``","Store (Write)", "May be used to write.",""
"``c``","Load / Store Capability", "May be used to load or store capabilities as well as non-capability data.","``R`` or ``W``"
"``m``","Load Mutable", "May be used to load capabilities with write permission.","``R``"
"``m``","Load Mutable", "May be used to load capabilities with write permission.","``R`` and ``c``"
"``g``","Load Global", " May be used to load capabilities with the global permission.","``R`` and ``c``"

Examples of valid encodings are: ``"RWcm"`` (all permissions), ``"R"`` (read
only), etc. Note that the order in which symbols appear is not relevant: for
example, `"RWcm"` and `"mcWR"` are both valid and entail the same permissions.

**Warning**: The ``<permissions_encoding>`` parameter is optional, and if no encoding is given ``"RWcm"`` is assumed.
**Warning**: The ``<permissions_encoding>`` parameter is optional, and if no encoding is given ``"RWcmg"`` is assumed.
}];
}


def CHERIOTSharedObjectDocs : Documentation {
def CHERIoTSharedObjectDocs : Documentation {
let Category = DocCatVariable;
let Content = [{
Indicates that the global it refers to must be treated as a cross-compartment
Expand All @@ -1521,7 +1522,7 @@ cross-compartment shared object. The target global must have the `extern` and
of the shared object. The ``"<permissions_encoding>"`` indicates the permissions
of the capability resulting from the import. The permissions encoding is a
string of variable length. The symbols allowed in the string are ``R``, ``W``,
``c`` and ``m``, whose meaning is explained in the table below.
``c``, ``m`` and ``g``, whose meaning is explained in the table below.


.. csv-table:: Supported Syntaxes
Expand All @@ -1530,13 +1531,14 @@ string of variable length. The symbols allowed in the string are ``R``, ``W``,
"``R``","Load (Read)", "May be used to read.",""
"``W``","Store (Write)", "May be used to write.",""
"``c``","Load / Store Capability", "May be used to load or store capabilities as well as non-capability data.","``R`` or ``W``"
"``m``","Load Mutable", "May be used to load capabilities with write permission.","``R``"
"``m``","Load Mutable", "May be used to load capabilities with write permission.","``R`` and ``c``"
"``g``","Load Global", " May be used to load capabilities with the global permission.","``R`` and ``c``"

Examples of valid encodings are: ``"RWcm"`` (all permissions), ``"R"`` (read
only), etc. Note that the order in which symbols appear is not relevant: for
example, `"RWcm"` and `"mcWR"` are both valid and entail the same permissions.

**Warning**: The ``<permissions_encoding>`` parameter is optional, and if no encoding is given ``"RWcm"`` is assumed.
**Warning**: The ``<permissions_encoding>`` parameter is optional, and if no encoding is given ``"RWcmg"`` is assumed.
}];
}

Expand Down
4 changes: 2 additions & 2 deletions clang/lib/AST/TypePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2106,10 +2106,10 @@ void TypePrinter::printAttributedAfter(const AttributedType *T,
case attr::CHERILibCall:
OS << "cheri_libcall";
break;
case attr::CHERIOTMMIODevice:
case attr::CHERIoTMMIODevice:
OS << "cheriot_mmio";
break;
case attr::CHERIOTSharedObject:
case attr::CHERIoTSharedObject:
OS << "cheriot_shared_object";
break;
case attr::CHERIoTSealedType:
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/CodeGen/Targets/RISCV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,17 +667,17 @@ class RISCVTargetCodeGenInfo : public CommonCheriTargetCodeGenInfo {
// `cheriot_cap_import` attribute in the generated LLVM IR, so that the
// back-end can generate the proper import entries and correctly
// translate references to this global.
if (VD->hasAttr<CHERIOTMMIODeviceAttr>()) {
auto *Attr = D->getAttr<CHERIOTMMIODeviceAttr>();
if (VD->hasAttr<CHERIoTMMIODeviceAttr>()) {
auto *Attr = D->getAttr<CHERIoTMMIODeviceAttr>();
llvm::CHERIoTGlobalCapabilityImportAttr CapImportAttr(
llvm::CHERIoTGlobalCapabilityImportAttr::MMIO,
Attr->getDeviceName(), Attr->getEncodedPermissions());
GVar->addAttribute(CapImportAttr.getAttrName(), CapImportAttr.str());
}

// Same for the `cheriot_shared_object(...)` attribute.
if (VD->hasAttr<CHERIOTSharedObjectAttr>()) {
auto *Attr = D->getAttr<CHERIOTSharedObjectAttr>();
if (VD->hasAttr<CHERIoTSharedObjectAttr>()) {
auto *Attr = D->getAttr<CHERIoTSharedObjectAttr>();
llvm::CHERIoTGlobalCapabilityImportAttr CapImportAttr(
llvm::CHERIoTGlobalCapabilityImportAttr::SharedObject,
Attr->getObjectName(), Attr->getEncodedPermissions());
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13504,14 +13504,14 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
// CHERIoT-specific check: if the decl has the `cheriot_mmio` or
// `cheriot_shared_object` attributes and also has an explicit definition, an
// error must be generated.
if (RealDecl->hasAttr<CHERIOTSharedObjectAttr>() ||
RealDecl->hasAttr<CHERIOTMMIODeviceAttr>()) {
if (RealDecl->hasAttr<CHERIoTSharedObjectAttr>() ||
RealDecl->hasAttr<CHERIoTMMIODeviceAttr>()) {
const IdentifierInfo *AttrName;

if (auto *Attr = RealDecl->getAttr<CHERIOTSharedObjectAttr>())
if (auto *Attr = RealDecl->getAttr<CHERIoTSharedObjectAttr>())
AttrName = Attr->getAttrName();
else {
AttrName = RealDecl->getAttr<CHERIOTMMIODeviceAttr>()->getAttrName();
AttrName = RealDecl->getAttr<CHERIoTMMIODeviceAttr>()->getAttrName();
}

Diag(RealDecl->getLocation(),
Expand Down
16 changes: 8 additions & 8 deletions clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2106,7 +2106,7 @@ static void handleCHERIMethodSuffix(Sema &S, Decl *D, const ParsedAttr &Attr) {
D->addAttr(::new (S.Context) CHERIMethodSuffixAttr(S.Context, Attr, Str));
}

static void handleCHERIOTMMIODevice(Sema &S, Decl *D, const ParsedAttr &Attr,
static void handleCHERIoTMMIODevice(Sema &S, Decl *D, const ParsedAttr &Attr,
Sema::DeclAttributeLocation DAL) {
auto *VD = dyn_cast<VarDecl>(D);
if (!VD || !VD->hasGlobalStorage())
Expand Down Expand Up @@ -2166,11 +2166,11 @@ static void handleCHERIOTMMIODevice(Sema &S, Decl *D, const ParsedAttr &Attr,
FailedSemanticCheckCallback))
return;

return D->addAttr(::new (S.Context) CHERIOTMMIODeviceAttr(
return D->addAttr(::new (S.Context) CHERIoTMMIODeviceAttr(
S.Context, Attr, DeviceName, OwnedPermissions));
}

static void handleCHERIOTSharedObject(Sema &S, Decl *D, const ParsedAttr &Attr,
static void handleCHERIoTSharedObject(Sema &S, Decl *D, const ParsedAttr &Attr,
Sema::DeclAttributeLocation DAL) {
auto *VD = dyn_cast<VarDecl>(D);
if (!VD || !VD->hasGlobalStorage())
Expand Down Expand Up @@ -2226,7 +2226,7 @@ static void handleCHERIOTSharedObject(Sema &S, Decl *D, const ParsedAttr &Attr,
FailedSemanticCheckCallback))
return;

D->addAttr(::new (S.Context) CHERIOTSharedObjectAttr(
D->addAttr(::new (S.Context) CHERIoTSharedObjectAttr(
S.Context, Attr, ObjectName, OwnedPermissions));
}

Expand Down Expand Up @@ -7501,11 +7501,11 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL,
case ParsedAttr::AT_CHERICompartmentName:
handleCHERICompartmentName(S, D, AL, DAL);
break;
case ParsedAttr::AT_CHERIOTMMIODevice:
handleCHERIOTMMIODevice(S, D, AL, DAL);
case ParsedAttr::AT_CHERIoTMMIODevice:
handleCHERIoTMMIODevice(S, D, AL, DAL);
break;
case ParsedAttr::AT_CHERIOTSharedObject:
handleCHERIOTSharedObject(S, D, AL, DAL);
case ParsedAttr::AT_CHERIoTSharedObject:
handleCHERIoTSharedObject(S, D, AL, DAL);
break;
case ParsedAttr::AT_CHERIoTSealedType:
handleCHERIoTSealedType(S, D, AL, DAL);
Expand Down
Loading