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
6 changes: 6 additions & 0 deletions flang/include/flang/Evaluate/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ class TargetCharacteristics {
IeeeFeatures &ieeeFeatures() { return ieeeFeatures_; }
const IeeeFeatures &ieeeFeatures() const { return ieeeFeatures_; }

std::size_t integerKindForPointer() { return integerKindForPointer_; }
void set_integerKindForPointer(std::size_t newKind) {
integerKindForPointer_ = newKind;
}

private:
static constexpr int maxKind{common::maxKind};
std::uint8_t byteSize_[common::TypeCategory_enumSize][maxKind + 1]{};
Expand All @@ -156,6 +161,7 @@ class TargetCharacteristics {
IeeeFeature::Io, IeeeFeature::NaN, IeeeFeature::Rounding,
IeeeFeature::Sqrt, IeeeFeature::Standard, IeeeFeature::Subnormal,
IeeeFeature::UnderflowControl};
std::size_t integerKindForPointer_{8}; /* For 64 bit pointer */
};

} // namespace Fortran::evaluate
Expand Down
4 changes: 4 additions & 0 deletions flang/include/flang/Tools/TargetSetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ namespace Fortran::tools {
if (targetTriple.isOSWindows())
targetCharacteristics.set_isOSWindows(true);

// Currently the integer kind happens to be the same as the byte size
targetCharacteristics.set_integerKindForPointer(
targetTriple.getArchPointerBitWidth() / 8);

// TODO: use target machine data layout to set-up the target characteristics
// type size and alignment info.
}
Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Semantics/resolve-names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6689,8 +6689,8 @@ void DeclarationVisitor::Post(const parser::BasedPointer &bp) {
"'%s' cannot be a Cray pointer as it is already a Cray pointee"_err_en_US);
}
pointer->set(Symbol::Flag::CrayPointer);
const DeclTypeSpec &pointerType{MakeNumericType(
TypeCategory::Integer, context().defaultKinds().subscriptIntegerKind())};
const DeclTypeSpec &pointerType{MakeNumericType(TypeCategory::Integer,
context().targetCharacteristics().integerKindForPointer())};
const auto *type{pointer->GetType()};
if (!type) {
pointer->SetType(pointerType);
Expand Down