mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-25 00:29:20 +00:00
Implement part of review feedback for address spaces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44933 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
794405e6aa
commit
d49e18d29f
@ -671,7 +671,8 @@ accessed through pointers.</p>
|
|||||||
<p>A global variable may be declared to reside in a target-specifc numbered
|
<p>A global variable may be declared to reside in a target-specifc numbered
|
||||||
address space. For targets that support them, address spaces may affect how
|
address space. For targets that support them, address spaces may affect how
|
||||||
optimizations are performed and/or what target instructions are used to access
|
optimizations are performed and/or what target instructions are used to access
|
||||||
the variable. The default address space is zero.</p>
|
the variable. The default address space is zero. The address space qualifier
|
||||||
|
must precede any other attributes.</p>
|
||||||
|
|
||||||
<p>LLVM allows an explicit section to be specified for globals. If the target
|
<p>LLVM allows an explicit section to be specified for globals. If the target
|
||||||
supports it, it will emit globals to the section specified.</p>
|
supports it, it will emit globals to the section specified.</p>
|
||||||
|
@ -194,6 +194,7 @@ namespace bitc {
|
|||||||
FUNC_CODE_INST_FREE = 18, // FREE: [opty, op]
|
FUNC_CODE_INST_FREE = 18, // FREE: [opty, op]
|
||||||
FUNC_CODE_INST_ALLOCA = 19, // ALLOCA: [instty, op, align]
|
FUNC_CODE_INST_ALLOCA = 19, // ALLOCA: [instty, op, align]
|
||||||
FUNC_CODE_INST_LOAD = 20, // LOAD: [opty, op, align, vol]
|
FUNC_CODE_INST_LOAD = 20, // LOAD: [opty, op, align, vol]
|
||||||
|
// FIXME: Remove STORE in favor of STORE2 in LLVM 3.0
|
||||||
FUNC_CODE_INST_STORE = 21, // STORE: [valty,val,ptr, align, vol]
|
FUNC_CODE_INST_STORE = 21, // STORE: [valty,val,ptr, align, vol]
|
||||||
FUNC_CODE_INST_CALL = 22, // CALL: [attr, fnty, fnid, args...]
|
FUNC_CODE_INST_CALL = 22, // CALL: [attr, fnty, fnid, args...]
|
||||||
FUNC_CODE_INST_VAARG = 23, // VAARG: [valistty, valist, instty]
|
FUNC_CODE_INST_VAARG = 23, // VAARG: [valistty, valist, instty]
|
||||||
|
@ -1050,7 +1050,7 @@ Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
|
|||||||
%type <StrVal> GlobalName OptGlobalAssign GlobalAssign
|
%type <StrVal> GlobalName OptGlobalAssign GlobalAssign
|
||||||
%type <StrVal> OptSection SectionString OptGC
|
%type <StrVal> OptSection SectionString OptGC
|
||||||
|
|
||||||
%type <UIntVal> OptAlign OptCAlign
|
%type <UIntVal> OptAlign OptCAlign OptAddrSpace
|
||||||
|
|
||||||
%token ZEROINITIALIZER TRUETOK FALSETOK BEGINTOK ENDTOK
|
%token ZEROINITIALIZER TRUETOK FALSETOK BEGINTOK ENDTOK
|
||||||
%token DECLARE DEFINE GLOBAL CONSTANT SECTION ALIAS VOLATILE THREAD_LOCAL
|
%token DECLARE DEFINE GLOBAL CONSTANT SECTION ALIAS VOLATILE THREAD_LOCAL
|
||||||
@ -1137,6 +1137,9 @@ FPType : FLOAT | DOUBLE | PPC_FP128 | FP128 | X86_FP80;
|
|||||||
LocalName : LOCALVAR | STRINGCONSTANT | PCTSTRINGCONSTANT ;
|
LocalName : LOCALVAR | STRINGCONSTANT | PCTSTRINGCONSTANT ;
|
||||||
OptLocalName : LocalName | /*empty*/ { $$ = 0; };
|
OptLocalName : LocalName | /*empty*/ { $$ = 0; };
|
||||||
|
|
||||||
|
OptAddrSpace : ADDRSPACE '(' EUINT64VAL ')' { $$=$3; }
|
||||||
|
| /*empty*/ { $$=0; };
|
||||||
|
|
||||||
/// OptLocalAssign - Value producing statements have an optional assignment
|
/// OptLocalAssign - Value producing statements have an optional assignment
|
||||||
/// component.
|
/// component.
|
||||||
OptLocalAssign : LocalName '=' {
|
OptLocalAssign : LocalName '=' {
|
||||||
@ -1316,17 +1319,10 @@ Types
|
|||||||
$$ = new PATypeHolder($1);
|
$$ = new PATypeHolder($1);
|
||||||
CHECK_FOR_ERROR
|
CHECK_FOR_ERROR
|
||||||
}
|
}
|
||||||
| Types '*' { // Pointer type?
|
| Types OptAddrSpace '*' { // Pointer type?
|
||||||
if (*$1 == Type::LabelTy)
|
if (*$1 == Type::LabelTy)
|
||||||
GEN_ERROR("Cannot form a pointer to a basic block");
|
GEN_ERROR("Cannot form a pointer to a basic block");
|
||||||
$$ = new PATypeHolder(HandleUpRefs(PointerType::get(*$1)));
|
$$ = new PATypeHolder(HandleUpRefs(PointerType::get(*$1, $2)));
|
||||||
delete $1;
|
|
||||||
CHECK_FOR_ERROR
|
|
||||||
}
|
|
||||||
| Types ADDRSPACE '(' EUINT64VAL ')' '*' { // Pointer type?
|
|
||||||
if (*$1 == Type::LabelTy)
|
|
||||||
GEN_ERROR("Cannot form a pointer to a basic block");
|
|
||||||
$$ = new PATypeHolder(HandleUpRefs(PointerType::get(*$1, $4)));
|
|
||||||
delete $1;
|
delete $1;
|
||||||
CHECK_FOR_ERROR
|
CHECK_FOR_ERROR
|
||||||
}
|
}
|
||||||
@ -2073,41 +2069,31 @@ Definition
|
|||||||
}
|
}
|
||||||
CHECK_FOR_ERROR
|
CHECK_FOR_ERROR
|
||||||
}
|
}
|
||||||
| OptGlobalAssign GVVisibilityStyle ThreadLocal GlobalType ConstVal {
|
| OptGlobalAssign GVVisibilityStyle ThreadLocal GlobalType ConstVal
|
||||||
|
OptAddrSpace {
|
||||||
/* "Externally Visible" Linkage */
|
/* "Externally Visible" Linkage */
|
||||||
if ($5 == 0)
|
if ($5 == 0)
|
||||||
GEN_ERROR("Global value initializer is not a constant");
|
GEN_ERROR("Global value initializer is not a constant");
|
||||||
CurGV = ParseGlobalVariable($1, GlobalValue::ExternalLinkage,
|
CurGV = ParseGlobalVariable($1, GlobalValue::ExternalLinkage,
|
||||||
$2, $4, $5->getType(), $5, $3);
|
$2, $4, $5->getType(), $5, $3, $6);
|
||||||
CHECK_FOR_ERROR
|
|
||||||
} GlobalVarAttributes {
|
|
||||||
CurGV = 0;
|
|
||||||
}
|
|
||||||
| OptGlobalAssign GVVisibilityStyle ThreadLocal GlobalType ConstVal
|
|
||||||
ADDRSPACE '(' EUINT64VAL ')' {
|
|
||||||
/* "Externally Visible" Linkage with address space qualifier */
|
|
||||||
if ($5 == 0)
|
|
||||||
GEN_ERROR("Global value initializer is not a constant");
|
|
||||||
CurGV = ParseGlobalVariable($1, GlobalValue::ExternalLinkage,
|
|
||||||
$2, $4, $5->getType(), $5, $3, $8);
|
|
||||||
CHECK_FOR_ERROR
|
CHECK_FOR_ERROR
|
||||||
} GlobalVarAttributes {
|
} GlobalVarAttributes {
|
||||||
CurGV = 0;
|
CurGV = 0;
|
||||||
}
|
}
|
||||||
| OptGlobalAssign GVInternalLinkage GVVisibilityStyle ThreadLocal GlobalType
|
| OptGlobalAssign GVInternalLinkage GVVisibilityStyle ThreadLocal GlobalType
|
||||||
ConstVal {
|
ConstVal OptAddrSpace {
|
||||||
if ($6 == 0)
|
if ($6 == 0)
|
||||||
GEN_ERROR("Global value initializer is not a constant");
|
GEN_ERROR("Global value initializer is not a constant");
|
||||||
CurGV = ParseGlobalVariable($1, $2, $3, $5, $6->getType(), $6, $4);
|
CurGV = ParseGlobalVariable($1, $2, $3, $5, $6->getType(), $6, $4, $7);
|
||||||
CHECK_FOR_ERROR
|
CHECK_FOR_ERROR
|
||||||
} GlobalVarAttributes {
|
} GlobalVarAttributes {
|
||||||
CurGV = 0;
|
CurGV = 0;
|
||||||
}
|
}
|
||||||
| OptGlobalAssign GVExternalLinkage GVVisibilityStyle ThreadLocal GlobalType
|
| OptGlobalAssign GVExternalLinkage GVVisibilityStyle ThreadLocal GlobalType
|
||||||
Types {
|
Types OptAddrSpace {
|
||||||
if (!UpRefs.empty())
|
if (!UpRefs.empty())
|
||||||
GEN_ERROR("Invalid upreference in type: " + (*$6)->getDescription());
|
GEN_ERROR("Invalid upreference in type: " + (*$6)->getDescription());
|
||||||
CurGV = ParseGlobalVariable($1, $2, $3, $5, *$6, 0, $4);
|
CurGV = ParseGlobalVariable($1, $2, $3, $5, *$6, 0, $4, $7);
|
||||||
CHECK_FOR_ERROR
|
CHECK_FOR_ERROR
|
||||||
delete $6;
|
delete $6;
|
||||||
} GlobalVarAttributes {
|
} GlobalVarAttributes {
|
||||||
|
@ -141,6 +141,7 @@ static void WriteTypeTable(const ValueEnumerator &VE, BitstreamWriter &Stream) {
|
|||||||
Abbv->Add(BitCodeAbbrevOp(bitc::TYPE_CODE_POINTER));
|
Abbv->Add(BitCodeAbbrevOp(bitc::TYPE_CODE_POINTER));
|
||||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
|
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
|
||||||
Log2_32_Ceil(VE.getTypes().size()+1)));
|
Log2_32_Ceil(VE.getTypes().size()+1)));
|
||||||
|
Abbv->Add(BitCodeAbbrevOp(0)); // Addrspace = 0
|
||||||
unsigned PtrAbbrev = Stream.EmitAbbrev(Abbv);
|
unsigned PtrAbbrev = Stream.EmitAbbrev(Abbv);
|
||||||
|
|
||||||
// Abbrev for TYPE_CODE_FUNCTION.
|
// Abbrev for TYPE_CODE_FUNCTION.
|
||||||
@ -198,16 +199,14 @@ static void WriteTypeTable(const ValueEnumerator &VE, BitstreamWriter &Stream) {
|
|||||||
break;
|
break;
|
||||||
case Type::PointerTyID: {
|
case Type::PointerTyID: {
|
||||||
const PointerType *PTy = cast<PointerType>(T);
|
const PointerType *PTy = cast<PointerType>(T);
|
||||||
// POINTER: [pointee type] or [pointee type, address space]
|
// POINTER: [pointee type, address space]
|
||||||
Code = bitc::TYPE_CODE_POINTER;
|
Code = bitc::TYPE_CODE_POINTER;
|
||||||
TypeVals.push_back(VE.getTypeID(PTy->getElementType()));
|
TypeVals.push_back(VE.getTypeID(PTy->getElementType()));
|
||||||
if (unsigned AddressSpace = PTy->getAddressSpace())
|
unsigned AddressSpace = PTy->getAddressSpace();
|
||||||
TypeVals.push_back(AddressSpace);
|
TypeVals.push_back(AddressSpace);
|
||||||
else
|
if (AddressSpace == 0) AbbrevToUse = PtrAbbrev;
|
||||||
AbbrevToUse = PtrAbbrev;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Type::FunctionTyID: {
|
case Type::FunctionTyID: {
|
||||||
const FunctionType *FT = cast<FunctionType>(T);
|
const FunctionType *FT = cast<FunctionType>(T);
|
||||||
// FUNCTION: [isvararg, attrid, retty, paramty x N]
|
// FUNCTION: [isvararg, attrid, retty, paramty x N]
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
; RUN: llvm-as < %s | llvm-dis |& grep {addrspace(22)} | count 5
|
; RUN: llvm-as < %s | llvm-dis |& grep {addrspace(22)} | count 5
|
||||||
|
|
||||||
%struct.mystruct = type { i32, i32 addrspace(33)*, i32, i32 addrspace(33)* }
|
%struct.mystruct = type { i32, i32 addrspace(33)*, i32, i32 addrspace(33)* }
|
||||||
@input = global %struct.mystruct zeroinitializer addrspace(42) ; <%struct.mystruct addrspace(42)*> [#uses=1]
|
@input = weak global %struct.mystruct zeroinitializer addrspace(42) ; <%struct.mystruct addrspace(42)*> [#uses=1]
|
||||||
@output = global %struct.mystruct zeroinitializer addrspace(66) ; <%struct.mystruct addrspace(66)*> [#uses=1]
|
@output = global %struct.mystruct zeroinitializer addrspace(66) ; <%struct.mystruct addrspace(66)*> [#uses=1]
|
||||||
@y = global i32 addrspace(11)* addrspace(22)* null addrspace(33) ; <i32 addrspace(11)* addrspace(22)* addrspace(33)*> [#uses=1]
|
@y = external global i32 addrspace(11)* addrspace(22)* addrspace(33) ; <i32 addrspace(11)* addrspace(22)* addrspace(33)*> [#uses=1]
|
||||||
|
|
||||||
define void @foo() {
|
define void @foo() {
|
||||||
entry:
|
entry:
|
||||||
|
Loading…
Reference in New Issue
Block a user