[flang][NFC] Replace "align" with "alignment"

In the places it is used as a noun, replace "align" with "alignment".

Differential Revision: https://reviews.llvm.org/D79520
This commit is contained in:
Tim Keith 2020-05-06 15:00:14 -07:00
parent 07b69dcf66
commit 54b35c0664
7 changed files with 43 additions and 43 deletions

View File

@ -190,8 +190,8 @@ public:
std::size_t size() const { return size_; }
void set_size(std::size_t size) { size_ = size; }
std::size_t align() const { return align_; }
void set_align(std::size_t align) { align_ = align; }
std::size_t alignment() const { return alignment_; }
void set_alignment(std::size_t alignment) { alignment_ = alignment; }
ImportKind GetImportKind() const;
// Names appearing in IMPORT statements in this scope
@ -229,7 +229,7 @@ private:
Scope &parent_; // this is enclosing scope, not extended derived type base
const Kind kind_;
std::size_t size_{0}; // size in bytes
std::size_t align_{0}; // required alignment in bytes
std::size_t alignment_{0}; // required alignment in bytes
parser::CharBlock sourceRange_;
Symbol *const symbol_; // if not null, symbol_->scope() == this
std::list<Scope> children_;

View File

@ -306,13 +306,13 @@ public:
void add_object(Symbol &object) { objects_.emplace_back(object); }
MaybeExpr bindName() const { return bindName_; }
void set_bindName(MaybeExpr &&expr) { bindName_ = std::move(expr); }
std::size_t align() const { return align_; }
void set_align(std::size_t align) { align_ = align; }
std::size_t alignment() const { return alignment_; }
void set_alignment(std::size_t alignment) { alignment_ = alignment; }
private:
MutableSymbolVector objects_;
MaybeExpr bindName_;
std::size_t align_{0}; // required alignment in bytes
std::size_t alignment_{0}; // required alignment in bytes
};
class FinalProcDetails {}; // TODO

View File

@ -30,13 +30,13 @@ public:
void Compute() { Compute(context_.globalScope()); }
private:
struct SizeAndAlign {
SizeAndAlign() {}
SizeAndAlign(std::size_t size) : size{size}, align{size} {}
SizeAndAlign(std::size_t size, std::size_t align)
: size{size}, align{align} {}
struct SizeAndAlignment {
SizeAndAlignment() {}
SizeAndAlignment(std::size_t size) : size{size}, alignment{size} {}
SizeAndAlignment(std::size_t size, std::size_t alignment)
: size{size}, alignment{alignment} {}
std::size_t size{0};
std::size_t align{0};
std::size_t alignment{0};
};
struct SymbolAndOffset {
Symbol *symbol{nullptr};
@ -50,16 +50,16 @@ private:
std::size_t GetOffset(SymbolAndOffset &);
std::size_t ComputeOffset(const EquivalenceObject &);
void DoSymbol(Symbol &);
SizeAndAlign GetSizeAndAlign(const Symbol &);
SizeAndAlign GetElementSize(const Symbol &, bool isSubstring = false);
SizeAndAlignment GetSizeAndAlignment(const Symbol &);
SizeAndAlignment GetElementSize(const Symbol &, bool isSubstring = false);
std::size_t CountElements(const Symbol &);
static std::size_t Align(std::size_t, std::size_t);
static SizeAndAlign GetIntrinsicSizeAndAlign(TypeCategory, int);
static SizeAndAlignment GetIntrinsicSizeAndAlignment(TypeCategory, int);
SemanticsContext &context_;
evaluate::FoldingContext &foldingContext_{context_.foldingContext()};
std::size_t offset_{0};
std::size_t align_{0};
std::size_t alignment_{0};
// symbol -> symbol+offset that determines its location, from EQUIVALENCE
std::map<MutableSymbolRef, SymbolAndOffset> dependents_;
};
@ -89,7 +89,7 @@ void ComputeOffsetsHelper::DoScope(Scope &scope) {
DoEquivalenceSet(set);
}
offset_ = 0;
align_ = 0;
alignment_ = 0;
for (auto &symbol : scope.GetSymbols()) {
if (!InCommonBlock(*symbol) &&
dependents_.find(symbol) == dependents_.end()) {
@ -98,14 +98,14 @@ void ComputeOffsetsHelper::DoScope(Scope &scope) {
}
for (auto &[symbol, dep] : dependents_) {
if (symbol->size() == 0) {
SizeAndAlign s{GetSizeAndAlign(*symbol)};
SizeAndAlignment s{GetSizeAndAlignment(*symbol)};
symbol->set_size(s.size);
symbol->set_offset(GetOffset(dep));
offset_ = std::max(offset_, symbol->offset() + symbol->size());
}
}
scope.set_size(offset_);
scope.set_align(align_);
scope.set_alignment(alignment_);
}
std::size_t ComputeOffsetsHelper::GetOffset(SymbolAndOffset &dep) {
@ -120,12 +120,12 @@ std::size_t ComputeOffsetsHelper::GetOffset(SymbolAndOffset &dep) {
void ComputeOffsetsHelper::DoCommonBlock(Symbol &commonBlock) {
auto &details{commonBlock.get<CommonBlockDetails>()};
offset_ = 0;
align_ = 0;
alignment_ = 0;
for (auto &object : details.objects()) {
DoSymbol(*object);
}
commonBlock.set_size(offset_);
details.set_align(align_);
details.set_alignment(alignment_);
}
void ComputeOffsetsHelper::DoEquivalenceSet(EquivalenceSet &set) {
@ -181,30 +181,30 @@ void ComputeOffsetsHelper::DoSymbol(Symbol &symbol) {
symbol.has<UseDetails>() || symbol.has<ProcBindingDetails>()) {
return; // these have type but no size
}
SizeAndAlign s{GetSizeAndAlign(symbol)};
SizeAndAlignment s{GetSizeAndAlignment(symbol)};
if (s.size == 0) {
return;
}
offset_ = Align(offset_, s.align);
offset_ = Align(offset_, s.alignment);
symbol.set_size(s.size);
symbol.set_offset(offset_);
offset_ += s.size;
align_ = std::max(align_, s.align);
alignment_ = std::max(alignment_, s.alignment);
}
auto ComputeOffsetsHelper::GetSizeAndAlign(const Symbol &symbol)
-> SizeAndAlign {
SizeAndAlign result{GetElementSize(symbol)};
auto ComputeOffsetsHelper::GetSizeAndAlignment(const Symbol &symbol)
-> SizeAndAlignment {
SizeAndAlignment result{GetElementSize(symbol)};
std::size_t elements{CountElements(symbol)};
if (elements > 1) {
result.size = Align(result.size, result.align);
result.size = Align(result.size, result.alignment);
}
result.size *= elements;
return result;
}
auto ComputeOffsetsHelper::GetElementSize(
const Symbol &symbol, bool isSubstring) -> SizeAndAlign {
const Symbol &symbol, bool isSubstring) -> SizeAndAlignment {
const DeclTypeSpec *type{symbol.GetType()};
if (!type) {
return {};
@ -218,10 +218,10 @@ auto ComputeOffsetsHelper::GetElementSize(
runtime::Descriptor::SizeInBytes(symbol.Rank(), false, lenParams)};
return {size, maxAlignment};
}
SizeAndAlign result;
SizeAndAlignment result;
if (const IntrinsicTypeSpec * intrinsic{type->AsIntrinsic()}) {
if (auto kind{ToInt64(intrinsic->kind())}) {
result = GetIntrinsicSizeAndAlign(intrinsic->category(), *kind);
result = GetIntrinsicSizeAndAlignment(intrinsic->category(), *kind);
}
if (!isSubstring && type->category() == DeclTypeSpec::Character) {
ParamValue length{type->characterTypeSpec().length()};
@ -235,7 +235,7 @@ auto ComputeOffsetsHelper::GetElementSize(
} else if (const DerivedTypeSpec * derived{type->AsDerived()}) {
if (derived->scope()) {
result.size = derived->scope()->size();
result.align = derived->scope()->align();
result.alignment = derived->scope()->alignment();
}
} else {
DIE("not intrinsic or derived");
@ -262,8 +262,8 @@ std::size_t ComputeOffsetsHelper::Align(std::size_t x, std::size_t alignment) {
return (x + alignment - 1) & -alignment;
}
auto ComputeOffsetsHelper::GetIntrinsicSizeAndAlign(
TypeCategory category, int kind) -> SizeAndAlign {
auto ComputeOffsetsHelper::GetIntrinsicSizeAndAlignment(
TypeCategory category, int kind) -> SizeAndAlignment {
// TODO: does kind==10 need special handling?
std::size_t size{kind == 3 ? 2 : static_cast<std::size_t>(kind)};
if (category == TypeCategory::Complex) {

View File

@ -354,7 +354,7 @@ void DoDumpSymbols(llvm::raw_ostream &os, const Scope &scope, int indent) {
os << ' ' << symbol->name();
}
if (scope.size()) {
os << " size=" << scope.size() << " align=" << scope.align();
os << " size=" << scope.size() << " alignment=" << scope.alignment();
}
if (scope.derivedTypeSpec()) {
os << " instantiation of " << *scope.derivedTypeSpec();

View File

@ -434,8 +434,8 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const Details &details) {
DumpSymbolVector(os, x.objects());
},
[&](const CommonBlockDetails &x) {
if (x.align()) {
os << " align=" << x.align();
if (x.alignment()) {
os << " alignment=" << x.alignment();
}
os << ':';
for (const auto &object : x.objects()) {

View File

@ -39,13 +39,13 @@ subroutine s3
character(kind=k, len=8) :: c3
character(kind=k, len=l) :: d3
end type
!CHECK: DerivedType scope: size=48 align=8 instantiation of t(k=2_4,l=10_4)
!CHECK: DerivedType scope: size=48 alignment=8 instantiation of t(k=2_4,l=10_4)
!CHECK: a3 size=2 offset=0:
!CHECK: b3 size=2 offset=2:
!CHECK: c3 size=16 offset=4:
!CHECK: d3 size=24 offset=24:
type(t(2, 10)) :: x3
!CHECK: DerivedType scope: size=64 align=8 instantiation of t(k=4_4,l=20_4)
!CHECK: DerivedType scope: size=64 alignment=8 instantiation of t(k=4_4,l=20_4)
!CHECK: a3 size=4 offset=0:
!CHECK: b3 size=4 offset=4:
!CHECK: c3 size=32 offset=8:

View File

@ -21,19 +21,19 @@ module mb
end
! equivalence and substring
subroutine mc !CHECK: Subprogram scope: mc size=12 align=1
subroutine mc !CHECK: Subprogram scope: mc size=12 alignment=1
character(10) :: c1 !CHECK: c1 size=10 offset=0:
character(5) :: c2 !CHECK: c2 size=5 offset=7:
equivalence(c1(9:), c2(2:4))
end
! Common block: objects are in order from COMMON statement and not part of module
module md !CHECK: Module scope: md size=1 align=1
module md !CHECK: Module scope: md size=1 alignment=1
integer(1) :: i
integer(2) :: d1 !CHECK: d1, PUBLIC size=2 offset=8:
integer(4) :: d2 !CHECK: d2, PUBLIC size=4 offset=4:
integer(1) :: d3 !CHECK: d3, PUBLIC size=1 offset=0:
real(2) :: d4 !CHECK: d4, PUBLIC size=2 offset=0:
common /common1/ d3,d2,d1 !CHECK: common1 size=10 offset=0: CommonBlockDetails align=4:
common /common2/ d4 !CHECK: common2 size=2 offset=0: CommonBlockDetails align=2:
common /common1/ d3,d2,d1 !CHECK: common1 size=10 offset=0: CommonBlockDetails alignment=4:
common /common2/ d4 !CHECK: common2 size=2 offset=0: CommonBlockDetails alignment=2:
end